aspose file tools*
The moose likes Struts and the fly likes validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validation" Watch "validation" New topic
Author

validation

MInu
Ranch Hand

Joined: Oct 09, 2003
Posts: 517
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


God Gave Me Nothing I Wanted<br />He Gave Me Everything I Needed<br /> - Swami Vivekananda
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
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

Joined: Jan 24, 2005
Posts: 12
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
 
 
subject: validation