Validation Of Email Id Which Given By User

  1. <html>  
  2.    <head>  
  3.       <title>Sample Code</title>  
  4.       <script type="text/javascript">  
  5.          function CheckEmail(strEmail)  
  6.          {           
  7.          var objRegex = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/;  
  8.            
  9.          //Check Here Email String  
  10.            
  11.          var test=objRegex.test(strEmail);  
  12.            
  13.          if(test=true)           
  14.          {           
  15.                alert("Your Given Email Id Is \""+strEmail+"\" Correct.");           
  16.          }           
  17.          else           
  18.          {           
  19.                alert("Your Given Email Id Is Not \""+strEmail+"\" Correct.");          
  20.          }  
  21.            
  22.          }  
  23.       </script>  
  24.    </head>  
  25.    <body bgcolor=#00ff00 alink=blue vlink=blue>  
  26.       <FORM name="windowEvent">  
  27.          Email : <input type="text" name="txtemail" />  
  28.          <input type="button" value="Check Email" name="btnEmail" onClick="CheckEmail(txtemail.value)" />  
  29.       </FORM>  
  30.    </body>  
  31. </html>