File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes validator in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validator in struts" Watch "validator in struts" New topic
Author

validator in struts

raghavendra vema
Greenhorn

Joined: Jun 12, 2005
Posts: 25
Hi

I am using Validator in struts for field level Validation, The validation criterion is length should be exactly 9 characters and can take either of the patterns described below

pattern 1: all 9 characters are Numbers

pattern 2: 1st character is an Alphabet and rest 8 characters are Numbers

What is the shortest way of achieving this validation?

Thanks
ragha


Raghavendra Vema SCJP 1.4 SCBCD 1.3
dnyan ginde
Ranch Hand

Joined: Jan 17, 2006
Posts: 68
As far as the validation for length goes, you can do it with validator-rules.xml by specifying the rule for length. But if you also want to validate for the 2 character sequences along with the length, then i would suggest you to combine the auto and manual validation. The validation for length can be done by the validator-rules.xml and put the logic for character validation in your form bean. You could also put this logic in the validator-rules.xml using the javascript tag. Or you could have javascript validation for character and auto validation for length. The choice is yours.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: validator in struts
 
Similar Threads
JavaServer Faces in Action: Reader question
Struts Validation Query: How to implement custom validations in struts?
number validation using validator
Struts client side validation for more than one textbox at same time
Validation ... best approach