Created
November 4, 2012 20:19
-
-
Save apphp-snippets/4013518 to your computer and use it in GitHub Desktop.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript"> | |
| /* Source: http://www.apphp.com/index.php?snippet=javascript-email-validation */ | |
| 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment