Validate Email Id using Regex and JQuery

  1. <script type="text/javascript">  
  2.     function ValidateEmail(email) {  
  3.         var expr = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;  
  4.         return expr.test(email);  
  5.     };  
  6.     $("#validator").live("click", function() {  
  7.         if (!ValidateEmail($("#txtMail").val())) {  
  8.             alert("Invalid email address.Please enter valid email address.");  
  9.         } else {  
  10.             alert("Valid email address.");  
  11.         }  
  12.     });  
  13. </script>  
  14. <input type="text" id="txtMail" />  
  15. <input type="button" id="validator" value="validate email" />