Though this solution may be simple, I'm sure this is one of those useful things that people will be Googling for and deserves its own entry on the site If only Google would be the first place to look :) Just look at the duplicates of this closed every some time. But, you know, technically speaking, you're demonstratively, provably wrong.(? This is by far the best solution to the original question. But keep in mind that one should not rely only upon Java Script validation. This should be validated on the server side as well. Yes, it uses HTML5, but the majority of applications that require this level of accuracy will surely already be relying on HTML5 in some other way anyway, so moot point. Here's an example of the above in action: ()[\]\\.,;:\[email protected]\"]+)*)|(\".+\"))@((\0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-z A-Z\-0-9]+\.)+[a-z A-Z]{2,}))$/; return re.test(email); } function validate() { $("#result").text(""); var email = $("#email").val(); if (validate Email(email)) { $("#result").text(email + " is valid :)"); $("#result").css("color", "green"); } else { $("#result").text(email + " is not valid :("); $("#result").css("color", "red"); } return false; } $("form").bind("submit", validate);@Good Person I just tried to email [email protected] to tell him/her they have a cool email address. I suspect whoever that is has bigger problems communicating with others via email than just my site's javascript validation! For all the people commenting that this is "good enough": look, you're simply thinking about this problem wrong. It's impossible for us to ever determine if someone's email is valid without getting them to verify it anyway, so we really should not be investing so much time or effort into validating it.

[[ validating user input in perl-44

I agree with @kommrad Homer here -- why send an email if you don't have to? If you would still find any shortcomings, I'll be happy to learn which.

An email address is The second regex in voyager's answer in stackoverflow.com/a/1373724/69697 is practical for use and should have almost no false negatives.

In short, however, the only way to be absolutely, positively sure that what the user entered is in fact an email is to actually send an email and see what happens. @kommrad Homer -- a "regex invalid" address is almost always valid, because whatever regex you use to validate an email address is almost certainly wrong and will exclude valid email addresses.

Combined with feature detection and the bare-bones validation from Squirtle's Answer, it frees you from the regular expression massacre and does not bork on old browsers. This is because according to the RFC that is a valid e-mail address (think intranets). If the user types in 'sexy_chick_23', then this regex can be used to give them a heads up that an e-mail is expected.

input.check Validity() : /\[email protected]\S+\.\S+/.test(value); } I've put together an example in the fiddle A good example would be if you want a person's username to be an e-mail address.

function validate Email(value) { var input = document.create Element('input'); = 'email'; input.value = value; return typeof input.check Validity == 'function' ? My 'agressively lazy' approach at least can be improved if required.+1 - If the objective is to make sure that the user has at least attempted to put in an e-mail address, then checking to see if it can be determined that the e-mail address is definitely NOT an e-mail is a great solution. :[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(? The following Java Script- and Perl-compatible regular expression is an implementation of the above definition. üñîçøðé@üñîçøðé(Unicode characters in domain part) 10. Yours is an example of what I'd call "aggressively lazy coding." I'm not sure why you are defending it as it is by far the lowest rated answer in the [email protected] maybe you are right. Differently from you I don't think though any of the code above shows easy to debug snippets. 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. At least evaluate for whether there is a domain or something that might be a domain. You can still keep it simple but do a little more to ensure it has a "." somewhere after the @ followed by only numbers or digits, so things like [email protected], [email protected]@, and [email protected] aren't valid... Nobody is going to enter that into an email field by accident, and that is all front-end validation is for: To prevent people from accidentally entering the wrong bit of information, such as their name, in an email field. Even if you could perfectly determine whether an email is RFC-syntactically valid, that wouldn't tell you whether it belongs to the person who supplied it. Now since you can only cover 90% of the cases, write something like: You can refine it. Your example allows "[email protected]" to be considered a valid email address. A regex on its own is unhelpful, but serves as a good complement to serverside validation. Java Script in frontend (not for backend use of cause) is not sufficient for validating for security reasons. Basic typos are: forget TLD or user-prefix (before @) or domain-part or mistype Don't bother with anything more complicated. It's too complicated and would not cover all the cases. There are many fine examples in this thread that validate further than "does it have an '@' in it. as long as it's written in quotes) NOBODY DOES THIS EVER. But, it IS included in the true RFC 2822 standard, and omitted here. I can understand reflexive dislike for incomprehensible regexes and desire to keep code simple, but this is a couple lines of code that can save your server a lot of trouble by immediately weeding out items that are definitely invalid. It will block spaces which are technically allowed by RFC, but they are so rare that I'm happy to do this. All these "complicated" answers produce problems: they either don't allow puny-code IDN or use a fixed set of TLDs or unnecessarily restrict the user to not use characters like [@çµ.ö in their email-prefix (before @) or domain name. I realize there's a mentality in these answers of only doing very basic email validation, but why would you allow the @ symbol to be at the beginning of the string when all you have to do is change -1 to 0 to make sure there's something before it? and removing a redundant backslash and ditto plus at the end, I can't find anything wrong with it. You should not use regular expressions to validate an input string to check if it's an email. A simple 90% solution is better than 100% solution that does not work. It doesn't have to be impossible to debug at all. $/i; console.log( email Check.test('[email protected]') ); Note: Technically some emails can include quotes in the section before the @ symbol with escape characters inside the quotes (so you're email user can be obnoxious and contain stuff like @ and "...