• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do u show multiple validation errors at once struts 1.2.4

 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 7306
45
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic