I am using the following jquery function to only allow numeric input. It works fine, but client now wants to limit input to 8 numeric values. Is there away, using the code below to also restrict the number of characters?
$(document).ready(function () {
$('input.numberinput').bind('keypress', function (e) {
return !(e.which != 8 && e.which != 0 &&
(e.which < 48 || e.which > 57) && e.which != 46);
});
});
Thank you in advance.
&& (this.value.length >= 8);in your current return statement and it should work fine.maxlengthattribute on the<input>tag?