hi guys,
so I'm using validator.xml to check my form.
In short: If the user will send a check - don't check for creditcard info. but if the checkBox is not checked- validate the nameOfuser on creditCard.
I need an 'if statment' and I do the following with validwhen:
struts-config.xml
<form-property name="check" type="java.lang.String" initial=""/>
<form-property name="nameOnCreditCard" type="java.lang.String" initial=""/>
jsp:
<td>
<html:checkbox property="check" value="true">Will send a check</html:checkbox><br>
<html:errors property="check" />
</td>
validation.xml
<field property="nameOnCreditCard" depends="validwhen">
<arg0 key="error.nameOnCreditCard.required"/>
<var>
<var-name>test</var-name>
<var-value>((check == false) or (*this* != null))</var-value>
</var>
</field>
so basically I'm asking this: if the user clicks the checkBox - will send a check - DO NOT CHECK for nameOnCreditCard (if it's empty - that's ok)
for somereason, any combination I'm trying doesn't work!!!
((check == false) or (*this* != null))
((check == true) or (*this* != null))
(check == false)
(check == true)
((check == 'false' ) or (*this* != null))
((check == 'true') or (*this* != null))
((check == '1 ) or (*this* != null))
((check == 1) or (*this* != null))
in other words, even if the checkbox is clicked or not (and it's working i checked) the nameOnCreditCard has an empty error message (suppose to show an error message if the checkBox is not clicked)
anyone?