Home

Tuesday, March 22, 2011

E-MAIL VALIDATION USING JAVASCRIPT

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;
}

1 comment:

  1. Thanks for giving this code.
    This code successfully run in my project.

    ReplyDelete

rathoddhirendra.blogspot.com-Google pagerank and Worth