Ever come across a form prompting for your e-mail address only to find out it won’t accept your perfectly legitimate handle, like romeo+juliet@shakespeare.ca? Theoretically you can also send mail to a user at an IP address instead of a domain name… so why are these false positives being thrown? Maybe it’s because the pattern to recognize a proper address is a complete retarded regular expression. When you factor in the escape characters of a programming language, who would want to re-implement this? Not to mention, there will soon no longer be a Latin alphabet stranglehold on e-mail addresses.
At this point, the most simple method is to check for a single @ sign with characters before and after. Perform the check in the web browser and also on server-side just in case JavaScript is disabled. In Javascript, the function will just look like this:
function validateForm(form) { if(!/^[^@]+@[^@]+$/.test(form.email.value.replace(/^\s+|\s+$/g, ''))) { alert("No, just no."); form.email.focus(); return false; } else { return true; } }
<form ... onsubmit="return validateForm(this)"> ... <input name="email" type="text" /> ... </form>
So why verify? You may break XHTML compliancy on <a href=”mailto:… tags? Prevent sending messages to multiple recipients by throwing a comma or semicolon in the input text field? Why are you even collecting the e-mail address in the first place? What will you use it for? Registration? I think I validate just as a matter of principal (also known as OCD) to ensure every bit in my database has integrity. It’s to the point where you really should just verify the address by attempting to fire off a message containing a clickable link to verify a hash saved to the database. Let your mailing API throw an exception if the address is invalid. Of course, when spam filters just kill the email, what’s the point?
This is where we have a web development existential crisis.

It’s both a blessing and a curse that web forms often don’t accept ‘+’ as part of an email address, in my opinion.
That’s just so you can avoid receiving spam, you sly Limey bastard.
How did you guess?!?