Learn how to validate a users email address using Java Script.
This tutorial displays a series of preset demonstrations that show different email address errors being trapped by the script.
Often, email validation code for web applications checks only for the position of @ and period characters, also assuming the @ character will be in the front of period. Did you know you can use a Java Script Regular Expressions method to check email addresses?
a CGI/Perl script on a Web server) sending a request to an Internet Mail Server, to check if the email address exists and if a connection would be accepted by the Mail Server.
However, browser-side validation can be very useful when used to filter out the more obvious mistakes in the syntax of an email address and if you are collecting email addresses for a database then browser-side validation is essential.
It is worth noting that our script only does seven validation checks whereas there are possibly dozens of other validation checks that could be done.
At best, you can only hope to filter the more obvious errors when using browser-side email Address validation.
Example: Directions: Simply cut and paste the below code into the section of your page.
It contains a form with one box that is checked for "email validity".Most Web users believe that you can only use a Domain Name (e.g. This belief is incorrect and the Internet Mail protocol does allow you to use an IP Number in an E-Mail Address.When using an IP Number the dotted decimal notation number must be enclosed in square brackets (e.g. [email protected]%*– email’s tld is only allow character and digit 9. [email protected]– email’s last character can not end with dot “.” 11. [email protected] -email’s tld which has two characters can not contains digit Here’s a unit test using test NG. [email protected] – “.a” is not a valid tld, last tld must contains at least two characters 4. mkyong()*@– email’s is only allow character, digit, underscore and dash 8.If you consider that there are omissions in our validation routines then you are free to add more checks to the script yourself and this may be a very good thing to do educationally, especially if you are learning Java Script.