You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Partha Pratim Dutta <pd...@sapient.com> on 2006/03/16 11:26:53 UTC
struts validator | validwhen rule not working
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
Re: struts validator | validwhen rule not working
Posted by Niall Pemberton <ni...@gmail.com>.
validwhen is server side only.
Niall
On 3/16/06, Partha Pratim Dutta <pd...@sapient.com> wrote:
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org