This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Struts and the fly likes validwhen - struts validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validwhen - struts validation" Watch "validwhen - struts validation" New topic

validwhen - struts validation

Gayatri Ganesh
Ranch Hand

Joined: Dec 23, 2003
Posts: 143

I need to validate a field called age only when a boolean isAge is true, ie age is a required field only when boolean isAge is true.
And also age should be an integer only. I

In my validation.xml I have :

<form name="/a/b/c">
<field property="age" depends="validwhen,required,integer">
<arg0 key="errors.invalid"/>
<var-value>((isAge == 'true') and (*this* == null))</var-value>
<msg key="error.age.integer" name="integer"/>

But I always get the error message, even if I enetered a valid age.
Can anyone please tell me what is wrong ?

jQuery in Action, 3rd edition
subject: validwhen - struts validation
It's not a secret anymore!