.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Email Validation through Javascript

Posted By:Athira Sreejith       Posted Date: February 23, 2009    Points: 10    Category: Javascript    URL: http://www.dotnetspark.com  
 

Below is the code to validate email using Javascript in ASP.Net.

SCRIPT>
function validateEmail(email)
{
var emailpat=/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
var matchArray=email.match(emailpat);
    if(matchArray==null)
     {
        return false;
     }
    return true;
}

function ValidateCtrl()
{
if(document.getElementById("txtFrndmailId").value=="")
 {
   alert("Enter Yuor Friend's E-MailId");
   document.frmpostresume.txtFrndmailId.focus();
   return false;  
 }
 if(document.getElementById("txtFrndmailId").value!="")
 {
  if(!validateEmail(document.getElementById("txtFrndmailId").value))
  {
   alert("Invalid Email Address");
    document.frmpostresume.txtFrndmailId.focus();
   return false;
  }
 }
}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend