/ Published in: JavaScript
URL: http://www.apphp.com/index.php?snippet=javascript-email-validation
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.
Expand |
Embed | Plain Text
<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>
You need to login to post a comment.
