Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding more than one validation to form field

 
shaf maff
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • 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
 
Bejoy Kaladhar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
I have managed to fix it. I used regex instead and that did the job.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic