I am using struts validator framework for client side & server side
validations. I am facing issue with validwhen rule. Validator rules like
'required', 'minlength', 'maxlength' are working fine. 

 

The form has 2 fields 

 

1.      Radio button - 'currentMember'. This has values "yes" & "no".   
2.      Text field - 'memberNumber'. 

 

I am trying to apply following validations on the above fields

 

1.      memberNumber field should not be blank when the value of the
currentMember is "yes" 
2.      memberNumber field should be blank when the value of
currentMember is "no". 

 

I have added following code in validation.xml to achieve the above
validation rule. 

 

            <field property="memberNumber" depends="validwhen">

            <arg0 key="registrationForm.memberNumber"/>

            <var>

                  <var-name>test</var-name>

                  <var-value>(((*this* != null) and (currentMember ==
"yes")) or (*this* == null))</var-value>

            </var>

     </field>

 

I have also added registrationForm.memberNumber key in
MessageResources.properties.

 

The validwhen rule is not working for any field in the form. 

 

If I view the source of generated html, I am not able to find validation
specific to 'memberNumber'.

 

Please let me know if you have a solution to this problem. 

 

Thanks
PD 

Reply via email to