Last active
October 28, 2015 10:55
-
-
Save khoand0000/9a2ccb4feda24cff3d08 to your computer and use it in GitHub Desktop.
validate inputs (number, email) by using pattern & show custom error messages.
suggestion: using http://parsleyjs.org/
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
<!-- number is positive --> | |
<input type="number" pattern="[0-9]+" /> | |
<!-- email --> | |
<input type="email" pattern="([a-z0-9_]+|[a-z0-9_]+\.[a-z0-9_]+)*@([a-z0-9]|[a-z0-9]+\.[a-z0-9]+)+\.([a-z]{2,4})" /> | |
<!-- Vietnamese phone --> | |
<input type="tel" pattern="0[0-9]{9,10}" /> | |
<!-- | |
show custom error messages | |
suggestion: http://parsleyjs.org/ | |
complex solution: http://stackoverflow.com/questions/13798313/set-custom-html5-required-field-validation-message | |
simple solution: http://stackoverflow.com/questions/10361460/how-can-i-change-or-remove-html5-form-validation-default-error-messages | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment