This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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
I agree. Here's the link:
subject: validation
Similar Threads
Validate multiple fields base on a requiredif
it gives like"phone no must be an integer"! why?
validator requiredIf checking two conds
Validation.xml....need some help
why no errors shown for password validation in struts 1.2.4