Validate an email
<html> <head> <title>A valid e-mail address</title> <script type="text/javascript"> var validEmail = "a@t.com"; var invalidEmail = "d@t"; var pattern = /^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/; var a = pattern.test(validEmail); var b = pattern.test(invalidEmail); document.write(validEmail + " is valid: " + a + ", " +invalidEmail + " is valid: " + b); </script> </head> <body> </body> </html>