File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes how do u show multiple validation errors at once struts 1.2.4 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how do u show multiple validation errors at once struts 1.2.4" Watch "how do u show multiple validation errors at once struts 1.2.4" New topic
Author

how do u show multiple validation errors at once struts 1.2.4

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
I have the following in validation.xml

<field
property="email"
depends="required,email">
<arg0 key="registration.email"/>
</field>

the following in the ApplicationResources.properties

errors.required={0} is required.
errors.email={0} is an invalid e-mail address.

registration.email= Email

I was wondering how would I show both the required and the email at once rather than the required first and once that is corrected the email error is displayed

thank you for your time
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

You could define two separate validations instead of combining both in one.

<field
property="email"
depends="required">
<arg0 key="registration.email"/>
</field>
<field
property="email"
depends="email">
<arg0 key="registration.email"/>
</field>

The question is, what's the point? It doesn't make much sense to me to show them both. If the user doesn't provide a required email address, then of course it is invalid. IMO, the errors messages should be mutually exclusive: if one is shown, the other one shouldn't.


Junilu - [How to Ask Questions] [How to Answer Questions]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how do u show multiple validation errors at once struts 1.2.4
 
Similar Threads
Struts e-mail validator doesn't handle null?
validating radio buttons using validator or validation-ruls.xml
Question About The validation.xml
Struts Password and Email server-side validation
Solved : Regular Expression for MMYY