• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Validwhen validator question

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two properties on a form (zip and country) and I would like to validate
a us-zip for country = 'USA' and canadian zip when the country is 'Canada'
How would one go about doing this using validwhen when I have the following
in my validation.xml

validator-custom-rules.xml..

<form-validation>
<global>
<!-- Zip -->
<constant>
<constant-name>us_zip</constant-name>
<constant-value>^\d{5}((-|\s)?\d{4})?$</constant-value>
</constant>
<constant>
<constant-name>canada_zip</constant-name>
<constant-value>[A-Z]\d[A-Z] \d[A-Z]\d</constant-value>
</constant>
</form-validation>


validation.xml...

<field property="zipcode" depends="validwhen, mask" page="1">
<arg0 key="Zip code" resource="false" />
<var>
<var-name>mask</var-name>
<var-value>${us_zip}</var-value>
</var>
<var>
<var-name>test</var-name>
<var-value>(country == "USA") and (*this* != null)))</var-value>
</var>
</field>

<field property="country" depends="mask, maxlength" page="1">
<arg0 key="Country" resource="false" />
</field>




Is it possible to add multiple tests to the validwhen validator
 
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic