• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

validation

 
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..
I want to validate a text field.The condition is the value entered should be in small letters....no digits or special characters permitted.

My validation.xml is


<field property="userId" depends="required">
<arg0 key="errors.userform.userid"/>
<var>
<var-name>mask</var-name>
<var-value>[a-z]</var-value>
</var>
</field>

It does'nt work.

Thanks
 
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Including a mask within the field tag isn't enough, you'll also need to specify that you want the mask procedure to be run by adding 'mask' to the depends attribute.
Struts Validator Reference (makes a great bookmark)
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Make sure the mask to start with "^" sign and end with "$" sign. Its new requirement since Struts 1.1. Also, "*" before "$" sign (at the end) tells that the lower case letters can occur any number of times

<field property="fieldName" depends="required, mask">
<msg name="mask" key="formName.fieldName.display_msg"/>
<arg0 key="formName.fieldName.display_name"/>
<var>
<var-name>mask</var-name>
<var-value>^[a-z]*$</var-value>
</var>
</field>

thx
Dhan Raj
 
I'm full of tinier men! And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic