Validate Email Address in Javascript

Below is a nice little Javascript RegularExpression to validate email addresses.

/^\[email protected][a-zA-Z_.]+?\.[a-zA-Z.]{2,3}$/

..and to use it..

if (/^\[email protected][a-zA-Z_.]+?\.[a-zA-Z.]{2,3}$/.test(email)) alert("Success"); else alert("Fail");
Code language: JavaScript (javascript)
Subscribe
Notify of
guest
3 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
saho
saho
10 months ago

This is very helpful

duncan
duncan
7 years ago

email = “[email protected]”;
email = “[email protected]”;

Christopher Allen-Poole
Christopher Allen-Poole
7 years ago

And if you have a .museum email address… you’ll just have to go out and get another email address.