The pattern attribute for regular expressions looks like a great addition. Obligatory comment that "no more...server side code to check if the user's input is a valid email" is clearly a terrible advice. Always validate on the server.
The pattern attribute for regular expressions looks like a great addition. Obligatory comment that "no more...server side code to check if the user's input is a valid email" is clearly a terrible advice. Always validate on the server.
Specifically, they've redefined the format of email addresses in a way that's much simpler and is actually amenable to regular expressions. "This requirement is a willful violation of RFC 5322, which defines a syntax for e-mail addresses that is simultaneously too strict (before the "@" character), too vague (after the "@" character), and too lax (allowing comments, whitespace characters, and quoted strings in manners unfamiliar to most users) to be of practical use here."
The spec even includes a Perl-compatible regex as an example. :)
[^ @]*@[^ @]*
will validate strings like `@example.com` and `joe@` and even a single `@`. Probably [^ @]+@[^ @]+
is what he wants, plus server side validation (that is the classic "click link to validate address" email).^[^ @]+@[^ @]+$
That said, HTML5 has something even better if the input is expected to be an email address: input@type=email
See http://www.w3.org/TR/html-markup/input.email.html for more details.