Saturday, 8 February 2014

javascript Email validation using regular Expression

 
<script>
var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
var email=document.getElementById("email").value;
    if(email.search(emailRegex)==-1) {
                    alert("You have entered an invalid email.");
                    return false;
                }

</script>

No comments:

Post a Comment