Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

validator in struts

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic