The regular expression for email validation is follows :
^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$
The JS script for email validation can be written as follows :
function email_validator(mail_id) {
var regexp=/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$/;
if (regexp.test(mail_id)) {
alert("This is a valid Email Id!!!");
return true;
}
else {
alert("This is an invalid Email Id!!!");
return false;
}
}
You must be logged in to post a comment.