-
-
Save waila7/e1f463e5125afab6dcd08828b3930f9a to your computer and use it in GitHub Desktop.
Change the language of error message for html5 required fields.
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
| /* | |
| |----------------------------------------------------------------------- | |
| | With HTML | |
| |----------------------------------------------------------------------- | |
| */ | |
| <input | |
| type="number" | |
| id="userProvidedHeight" | |
| min="211" | |
| max="400" | |
| placeholder="211 — 400" | |
| oninvalid="setCustomValidity('Ingresa un numero entre 211 y 400.')" | |
| oninput="setCustomValidity('')" | |
| required | |
| /> | |
| /* | |
| |----------------------------------------------------------------------- | |
| | With jQuery | |
| |----------------------------------------------------------------------- | |
| */ | |
| <script> | |
| $('input[type="email"]') | |
| .on('invalid', function(){ | |
| return this.setCustomValidity('Ingresa una dirección de correo válida.'); | |
| }) | |
| .on('input', function(){ | |
| return this.setCustomValidity(''); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment