• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validator Problem?

 
John Rainey
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using struts 1.1b3 release. When I am doing validation, I set up 2 fields in my validation.xml file. I have both fields as required. Field 1 has to also validate a minlength and Field 2 has to validate against a range. The following will illustrate the issue I'm having.
Situation #1
Field 1: (leave blank)
Field 2: (leave blank)
Error Messages:
Field 1 is required
Field 2 is required
Situation #2
Field 1: hello (this should fail validation)
Field 2: (leave blank)
Error Messages:
Field 2 is required
In situation #2, I would also expect an error message from Field 1 stating that it does not meet the minlength rule. Instead, it looks like the validator is making the user enter in all of the required fields before going forward with any validation.
I was wondering if anyone else had noticed this behavior??
Thanks
 
Matthew Marquand
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm no validator guru on struts other than playing with it a bit. However, if memory serves me right, if you look at the javascript generated for the button, you'll see that it sequentially calls each generated javascript function. If the called function says it failed validation, then it stops.
Long story short. It will only emit errors for one "kind of" validation and those must be fixed before it will even attempt to validate other aspects of the properties on the page.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is only true for the JavaScript validation. Server side validation will report both errors.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic