<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: How do validate an entered e-mail adress (JSF dialog)?</title><link>https://answers.axonivy.com/questions/1167/how-do-validate-an-entered-e-mail-adress-jsf-dialog</link><description>&lt;p&gt;I would like to check if an entered e-mail adress is valid or not.
I know IVY uses JSR 303 validations, but unfortunately there is no e-mail validation?
Can anybody provide a small IVY project sample?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1167/how-do-validate-an-entered-e-mail-adress-jsf-dialog" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 19 Feb 2015 11:58:56 -0500</lastBuildDate><item><title>Answer by peter_muc</title><link>https://answers.axonivy.com/questions/1167/how-do-validate-an-entered-e-mail-adress-jsf-dialog/1171</link><description>&lt;p&gt;Thanks for your help Reguel!
I have found an additional helpful link:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.primefaces.org/showcase/ui/csv/custom.xhtml"&gt;http://www.primefaces.org/showcase/ui/csv/custom.xhtml&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">peter_muc</dc:creator><pubDate>Thu, 19 Feb 2015 11:58:56 -0500</pubDate><guid>https://answers.axonivy.com/questions/1167/how-do-validate-an-entered-e-mail-adress-jsf-dialog/1171</guid></item><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/1167/how-do-validate-an-entered-e-mail-adress-jsf-dialog/1169</link><description>&lt;p&gt;You can use bean validation of type regex to validat mail addresses. I've created a &lt;a href="https://www.dropbox.com/s/qxfhdd2f7ekruyn/BeanValidationEMail.iar?dl=0"&gt;demo IAR here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The approach is quite simple. I use a normal java bean with an annotated e-mail field. This java class is used on a JSF dialog and therefore annotations are automatically validated.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class Person 
{
  /**
  * @see &lt;a href="http://www.regular-expressions.info/email.html"&gt;http://www.regular-expressions.info/email.html&lt;/a&gt;
  */
  @Pattern(message="mail address is invalid", 
        regexp="[a-z0-9!#$%&amp;amp;'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&amp;amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")
  @NotNull(message="&amp;lt;%=ivy.cms.co(\"/ch.ivyteam.htmldialog.demo/BeanValidationDemo/notnull\")%&amp;gt;")
  private String email;

  public String getEmail() {
    return email;
  }
  public void setEmail(String email) {
    this.email = email;
  }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Bean validation compared to in view validation (as shown by roland) has an advantage. You can re-use the validation on every dialog where you use the bean without writing extra code. So define validation once, have a valid state everywhere...&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Wed, 18 Feb 2015 09:27:50 -0500</pubDate><guid>https://answers.axonivy.com/questions/1167/how-do-validate-an-entered-e-mail-adress-jsf-dialog/1169</guid></item><item><title>Answer by roland</title><link>https://answers.axonivy.com/questions/1167/how-do-validate-an-entered-e-mail-adress-jsf-dialog/1168</link><description>&lt;p&gt;Hi Peter,&lt;/p&gt;
&lt;p&gt;i used following validater for the Inputfield&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt; p:inputText id="email" value="#{data.tmpEmailAddress}" validatorMessage="Invalid email format"&amp;gt;
&amp;lt; f:validateRegex pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" /&amp;gt;
&amp;lt; /p:inputText&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;hope that helps.&lt;/p&gt;
&lt;p&gt;Roland&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">roland</dc:creator><pubDate>Wed, 18 Feb 2015 09:25:26 -0500</pubDate><guid>https://answers.axonivy.com/questions/1167/how-do-validate-an-entered-e-mail-adress-jsf-dialog/1168</guid></item></channel></rss>