How to email validation in javascript here are the steps its easy to do email validation in javascript
Example of valid email id
yourweb@example.me.net
yoursite@example.com
you.example@example.org
Example of invalid email id
.example@mysite.org [ an email should not be start with "." ]
example()*@gmail.com [ here the regular expression only allows character, digit, underscore, and dash ]
example..1234@Gmail.com [double dots are not allowed]
mysite.example.com [@ is not present]
mysite@.com.my [ tld (Top Level domain) can not start with dot "." ]
@you.example.net [ No character before @ ]
example123@gmail.b [ ".b" is not a valid tld ]
example@.org.org [ tld can not start with dot "." ]
JavaScript code to validate an email id
Example of valid email id
yourweb@example.me.net
yoursite@example.com
you.example@example.org
Example of invalid email id
.example@mysite.org [ an email should not be start with "." ]
example()*@gmail.com [ here the regular expression only allows character, digit, underscore, and dash ]
example..1234@Gmail.com [double dots are not allowed]
mysite.example.com [@ is not present]
mysite@.com.my [ tld (Top Level domain) can not start with dot "." ]
@you.example.net [ No character before @ ]
example123@gmail.b [ ".b" is not a valid tld ]
example@.org.org [ tld can not start with dot "." ]
JavaScript code to validate an email id
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(mail)) {
alert('Please provide a valid email address');
email.focus;
return false;
}
if (!filter.test(mail)) {
alert('Please provide a valid email address');
email.focus;
return false;
}
No comments:
Post a Comment