Brammam’s Weblog

Email validation

May 31, 2008 · No Comments

checking email validation by java script.

aspx page

<script language=”javascript” type=”text/javascript”>

function checkmail()

{

var emailfilter = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

     var MailID = document.getElementById(’txtMailID’);

     var returnval=emailfilter.test(MailID.value)

     if (returnval==false)

      {

         alert(”Please enter a valid email address.”);

        MailID.focus();
      }

     return returnval;

}

<script>

<asp:Button ID=”btnSubmit” runat=”server” Text=”Submit” />

then add an attribute in codebehind file to submit buttion

 btnSubmit.Attributes.Add(

“OnClick”, “return checkmail();”
 its equal to email validator in .net

Categories: Java Script

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment