This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validation" Watch "validation" New topic


Ranch Hand

Joined: Oct 09, 2003
Posts: 517
I want to validate a text field.The condition is the value entered should be in small digits or special characters permitted.

My validation.xml is

<field property="userId" depends="required">
<arg0 key="errors.userform.userid"/>

It does'nt work.


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

Joined: Jan 24, 2005
Posts: 12

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"/>

Dhan Raj
It is sorta covered in the JavaRanch Style Guide.
subject: validation
It's not a secret anymore!