Below javascript is used to valid email address using Regular Expression.
function validate()
{
//Here 'form1' is name of form. & 'email' is name of Email Text box.
var address = document.form1.email.value;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(reg.test(address) == false) {
alert('Invalid Email Address');
document.form1.email.focus();
return false;
}
return true;
}
function validate()
{
//Here 'form1' is name of form. & 'email' is name of Email Text box.
var address = document.form1.email.value;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(reg.test(address) == false) {
alert('Invalid Email Address');
document.form1.email.focus();
return false;
}
return true;
}
Thanks for giving this code.
ReplyDeleteThis code successfully run in my project.