Created
April 4, 2012 03:01
-
-
Save boyofgreen/2297441 to your computer and use it in GitHub Desktop.
HTML5 Hacks 2.7
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
input[type=number]{border: 2px solid green} | |
input:invalid {border: 2px solid red} |
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
<form name="myForm"> | |
Pick a number, any number between 1 and 5: <input type="number" name="quantity" min="1" max="5" /> <br /> | |
<input type="submit" name="mySubmit" /> | |
</form> |
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
document.myForm.quantity.addEventListener('input', function(e){this.checkValidity()}, false); | |
document.myForm.quantity.addEventListener('invalid', function(e){ | |
alert('Your Number needs to be between 1 and five, you choose '+this.value+'.') | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment