Return to Snippet

Revision: 62643
at March 4, 2013 20:16 by apphp-snippets


Initial Code
<script type="text/javascript">  
function check_email(email){  
    var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if(reg.test(email)){
        return true; 
    }else{  
        return false;
    }  
}  
</script>  
 
<input type="text" id="email">
<button onclick="alert(check_email(document.getElementById('email').value))">Validate</button>

Initial URL
http://www.apphp.com/index.php?snippet=javascript-email-validation

Initial Description
One of the important things about user input is to verify that the user has supplied the email that you have requested. The function below allows you to verify email address with easy.

Initial Title
Email Validation in JavaScript

Initial Tags
email, javascript, validation

Initial Language
JavaScript