• 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

Adding more than one validation to form field

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys

I am using the actionClass-validation.xml method to validate form inputs. I have one field which I want to valid several things, the first I have already implemented and that is if the field is empty. The other two validations I want to implement are (1) Length of string, it must be 11 chars and (2) All chars must be numbers only. Here is what I have done so far:

actionClass-validation.xml


actionClass.java
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello...just try out this piece of coe for validator xml file.I'm sure the string length validator would work fine not sure of the int validator.Give a try.



You can do the same without the short-circuit attribute also.
[ December 19, 2008: Message edited by: Bejoy KS ]
 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
The max char works perfectly fine, but the int one doesn't work at all. If I enter letters it will still work when it shouldnt. And if I submit it the action class spits out the following error:



I tried to convert the value from int to string before storing it but everytime I would submit the form the contactno field would just turn blank.
 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have managed to fix it. I used regex instead and that did the job.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic