Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

order of validation

 
Oliver Moore
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic