/ Published in: JavaScript
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
Copy this code and paste it in your HTML
<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>
URL: http://www.apphp.com/index.php?snippet=javascript-email-validation