This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes order of validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "order of validation" Watch "order of validation" New topic

order of validation

Oliver Moore
Ranch Hand

Joined: Mar 04, 2003
Posts: 44
Hi All,

I have 3 elements on a form I wish to validate. All three elements are required, but one is an email so I am applying the email rule to it as well. However, when the form is submitted, the JS error regarding the email formatting is only returned if all three fields are populated. If I submit an invalid email address with the 2 other required elements empty, only errors for the missing elements are displayed.

Is this normal behaviour or am I doing something obviously wrong? I would expect an error to be displayed for the first level of testing an element failed at.

Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
This is the normal behaviour for javascript validation. If you see the dynamic content generated by <html:javascript>, you will notice that validation is not performed field-wise but based on the type of validation. So you would have the required validation being performed first (for all fields), followed by email (for all fields) and so on.
I agree. Here's the link:
subject: order of validation
Similar Threads
access child elements in parent form
jquery.validate and tabber.js problems validating
Hidden elements in netscape-******
a4j:repeat and generated Id problem
Struts Form with only Submit Form Elements