Created
March 11, 2013 14:46
-
-
Save ccschmitz/5134744 to your computer and use it in GitHub Desktop.
Some JS to ensure that a user doesn't enter a value that is less than or greater than the min/max values allowed for a number input.
This file contains 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
$('#element').change(function() { | |
var $this = $(this); | |
if ($this.val() > $this.attr('max')) { | |
$this.val($this.attr('max')); | |
} else if ($this.val() < $this.attr('min')) { | |
$this.val($this.attr('min')); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment