Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validation

 
MInu
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
  • 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
 
Ray Stojonic
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
  • 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)
 
Dhan Raj
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic