Hacker News new | past | comments | ask | show | jobs | submit login

This regexp

    [^ @]*@[^ @]*
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).



Forgot the SOL/EOL markers; the above will still match a substring, e.g. xxx@xxx@xxx.com. Try:

^[^ @]+@[^ @]+$

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.


Thanks for the suggestion, i will check that :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: