newton rutgers wrote:
Hello All,

Can i do the conditional validation. For example if i have a drop down and the default value is "Please select one". if user dosen't select anything. validation won't show that it is required field to select. can anyone please help. Also how do i validation for radio button to see that user select something.

the entry in my validation.xml looks like this:

<field    property="product"
               depends="required,mask">
                 <msg name="mask" key="myForm.product.maskmsg"/>
                 <arg0 key="myForm.product.displayname"/>
                     <var>
                      <var-name>mask</var-name>
                      <var-value>^\w+$</var-value>
                    </var>

        </field>

Newt, sorry, just noticed your thread was hijacked and you never got an answer. What you're looking for to perform conditional validation is the 'validwhen' validation rule [1]. For your dropdown select case you can just use 'required'. For the radio buttons, if they each have the same name 'required' will work there too. If the radio buttons each have a different name, you'll need to use 'validwhen' to construct a condition for each radio button that says it is valid if '(radio1 != null) or (radio2 != null) or ...'.

L.

[1] http://struts.apache.org/struts-doc-1.2.8/userGuide/dev_validator.html#validwhen


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to