Prev Demo
JavaScript
>
Email Validation
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Validate Email in JavaScript</h1> <input type="text" id="email" /> <button onclick="Validate()">Validate Email</button> <script> function Validate(){ var mail = document.getElementById("email").value; alert(ValidateEmail(mail)); } function ValidateEmail(mail) { var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; return re.test(mail); } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output