Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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 (xxx@xxx.xxx) 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic