struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Turner" <tur...@blackbear.com>
Subject RE: 1.1-rc1 and Validator
Date Wed, 19 Mar 2003 14:57:24 GMT
Check out the "requiredif" validator, you can use it with the NULL
condition to require one field if the other one is null.

James

> -----Original Message-----
> From: Steve [mailto:sms687@neca.com] 
> Sent: Wednesday, March 19, 2003 9:27 AM
> To: struts-user@jakarta.apache.org
> Subject: 1.1-rc1 and Validator
> 
> 
> I have just recently begun to utilize the validator in our 
> application and had I simple question that I could not find 
> an answer to searching the archives. I have a search form 
> that a user can enter in 1..n criteria for searching. In a 
> simple case there are two input fields. The validation should 
> ensure that at least one of the fields are populated prior to 
> submitting the form. How would I configure my validation.xml 
> for this case? I currently have the following:
> 
>  <form name="TestSearchForm">
> 	<field
>       	property="someCriteria"
>             depends="required,minlength">
>             <msg name="required" key="errors.required"/>
>             <arg0 key="searchForm.someCriteria"/>
>             <arg1 name="minlength" key="${var:minlength}" 
> resource="false"/>
> 
>             <var>
>            	  <var-name>minlength</var-name>
>               <var-value>5</var-value>
>             </var>
>       </field>
>       <field property="otherCriteria"
>                     depends="required">
> 		<msg name="required" key="errors.required"/>
>             <arg0 key="searchForm.otherCriteria"/>
>       </field>
>  </form>
> 
> Which works exactly as you would expect requiring that both 
> fields are populated. Thanks.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message