File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
It's not a secret anymore!