wood burning stoves 2.0*
The moose likes Struts and the fly likes Validator..How to stop the validation after the first field? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validator..How to stop the validation after the first field?" Watch "Validator..How to stop the validation after the first field?" New topic
Author

Validator..How to stop the validation after the first field?

Umar Hathab Abdullah
Greenhorn

Joined: Jan 23, 2003
Posts: 18
Hi,
I have two text fields in my form. I am using the validator for the form validation.
What happens is that when I submit the form, I get the validation message for both the fields like " Name is required field,Password is required field".
Please write me how can I stop the validation so that I can display one one message.
Thanks,
Umar
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

Umar,
You don't actually have to stop the validation. You just have to hide the messages. Instead of looping through the list of error messages, you can display the first one.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Umar Hathab Abdullah
Greenhorn

Joined: Jan 23, 2003
Posts: 18
Thanks Jeanne,
But will you tell me how this is possible when doing the client side javascript validation.
I would also like to know how we can hide the messages both for server side and client side validations.
I am new to validator and I wud greatly appreciate the help.
Regards,
Umar
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
Depends how good you are at JavaScript. (I am not the greatest at it, but get by).
You can customize the JavaScript that gets output to the browswer.
Look inside validator-rules.xml file in your WEB-INF directory.


Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
 
wood burning stoves
 
subject: Validator..How to stop the validation after the first field?
 
Similar Threads
required validation problem
Struts Validator Framework:1 action class, 1 form, different fields validation
struts2 radio button validation
Validation Struts2
Commons validator - validwhen