I have an input box that takes values from 0-100. I want to prevent users from writing anything larger or smaller.
I've been using the jquery keyfilter plugin to limit the input of a field: http://code.google.com/p/jquery-keyfilter/
This plugin can limit the input to numerals, but not within a range. How do I prevent users from entering numbers that would exceed the range. Thanks.
Use plain Javascript like this:
Then declare the input box like this:
Because you have hooked this function to onchange(), it will work even if a user copy / pastes something into the input box.
If its just for number of characters not exceeding 20 (for example), then you can use
If you need to handle some other cases in the input field, then a function would be a better option.