You can use bean validation of type regex to validat mail addresses. I've created a [demo IAR here][1].
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.
public class Person
{
/**
* @see http://www.regular-expressions.info/email.html
*/
@Pattern(message="mail address is invalid",
regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")
@NotNull(message="<%=ivy.cms.co(\"/ch.ivyteam.htmldialog.demo/BeanValidationDemo/notnull\")%>")
private String email;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
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...
[1]: https://www.dropbox.com/s/qxfhdd2f7ekruyn/BeanValidationEMail.iar?dl=0