Switch to full style
JavaScript code examples
Post a reply

Email validation in Javascript

Tue Sep 13, 2011 11:03 pm

Email validation in Javascript based on pattern expression
Code:

<html>  
<title>email validation</title>  
    
<script language="JavaScript" type="text/javascript">  
    
// Validate Email .
    function validateEmail(email){  
 
    var reg 
= /^([A-Za-z0-9_-.])+@([A-Za-z0-9_-.])+.([A-Za-z]{2,4})$/;
      if (reg.test(email)) {   
       document
.getElementById("errorDiv").innerHTML = "This email is valid.";
      }else{  
       document
.getElementById("errorDiv").innerHTML = "This email is not valid.";
      }  
    
}  
    </script>
  
    <table>
    <tr><td>
    <input type="text" id="email" name="email"  />   
    <input type="button" onclick="validateEmail(email.value);" value="check Email" /><br/>
    <div id="errorDiv"/>  

     </td>    
    </tr>
    </table>
</html>
    




Post a reply
  Related Posts  to : Email validation in Javascript
 email adress validation and regular expression     -  
 validation using JavaScript     -  
 Javascript Validation On Multiple Select Lists     -  
 Javascript select menu validation issue     -  
 Send an email in asp.net     -  
 Send email in asp     -  
 send email from ASP using CDOSYS     -  
 Reading email in Python     -  
 Send email link example.     -  

Topic Tags

JavaScript Validation