title: JavaScript Validation for Email Id
body: <h3>Duplicate :</h3>
  
  <blockquote>
    <p><a href="https://stackoverflow.com/questions/46155/validate-email-address-in-javascript">Validate email address in JavaScript?</a></p>
  </blockquote>
  
  <p>I want to validate emailid using JavaScript. I am using following code:</p>
  
  <pre><code>var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/ ;
  var emailid=document.getElementById("&lt;%=txtEmail.ClientID %&gt;").value; 
  var matchArray = emailid.match(emailPat);
  if (txtemail.value!="")
  {  
    if (matchArray == null)
    {
          alert("Your email address seems to be incorrect. \n Please type the proper email address and try again.") 
          return false
    }
  }
  </code></pre>
  
  <p>This code is working for emails like, abc@xyz.com</p>
  
  <p>But when i enter valid mailid like ab.cd@xyz.com or abc@xy-z.com, it is showing alert. 
  What changes should I do in my coding, so it will not show alert for valid mail ids like above? Can anyone give me suggestions?</p>