• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Group variable validation

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guru's

I have a issue with a group variable validation using struts commons validation, any help will be appreciated.

I have a phone field (it is made of 4 text fields 3-3-4-5, last field being for extension)

eg. 646-787-7868-98989

I having tough time creating a validation rule for it.

the rules are:
1. All text fields should be numeric
2. Phone (all combined) is a required field
2. Ext field is optional

Please help.

thanks
raj
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just make the first 3 fields required and integer. The last field is integer.
 
sriraj anandhi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply, but my problem is I want to display the error message for the full phone number only once. As the the phone number is captured in separate fields I getting the error message four times.

Any help will be appreciated.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use the Struts validation framework and define four fields, you're going to get four error messages. There's no way around this with the "out of the box" validation framework.

You have 2 choices:

1-Remove the validation rules for all four fields. Then override the validate() method of your ActionForm. Manually code the logic for this validation, then call super.validate() to handle the other validation framework validations.

2-Create a custom validation rule that will handle this situation.

This link gives an example of how to code a custom validation rule.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic