File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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
It's not a secret anymore!