• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Struts e-mail validator doesn't handle null?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a form that has 2 e-mail fields. One is the entry field with an "add-email" button next to it that, when clicked, adds the e-mail to a CSV list in the other (locked) e-mail field. this is part of an overall form. Apparently, the built in Struts e-mail validator doesn't handle a null condition because it is allowing me to submit a null with the add-email button. I can't set it as required or the main form won't let me submit without an e-mail in that field which should be empty upon final form submission. The user should have clicked add-email to populate whats in the e-mail field to the CSV list of e-mails.

What can I do here? the Struts e-mail validator works in ensuring the correct format ([email protected]) but somehow it interprets nothing as being a correct e-mail too...

Thanks
~Ryan
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<field property="email" depends="required , email">
<arg0 key="form.email"/>
</field>

use this in your validation.xml file
 
Ryan White
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't do that because then it is required for the main form on the page. This is another form within the main form. The e-mail field has an add-email button that adds whatever is in that field to a text box with a list of multiple e-mail addresses. So when the user goes to submit the main form, they should have added the email in the email field to the multi e-mail text box therefore making the email field blank upon final submission.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What version of Struts are you using? Maybe you could use the validwhen rule? Or when the user pressed the Add button, you could populate a hidden field and perform validation against that field.

- Brent
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic