I'd like to use the new <input type="email" /> element. I'd like to have Java code that implements the same validation on the server that happens in the browser.
The HTML5 spec defines email addresses in ABNF as:
1*( atext / "." ) "@" ldh-str *( "." ldh-str )
<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
<let-dig-hyp> ::= <let-dig> | "-"
<let-dig> ::= <letter> | <digit>
<letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case
<digit> ::= any one of the ten digits 0 through 9
and:
atext           =   ALPHA / DIGIT /    ; Printable US-ASCII
                       "!" / "#" /        ;  characters not including
                       "$" / "%" /        ;  specials.  Used for atoms.
                       "&" / "'" /
                       "*" / "+" /
                       "-" / "/" /
                       "=" / "?" /
                       "^" / "_" /
                       "`" / "{" /
                       "|" / "}" /
                       "~"
These are not the same rules as in RFC 5322. How can I test that an address complies with these rules in Java?
Thanks!
 
     
     
    