jquery: numeric input only, but also restrict number of characters -
i using following jquery function allow numeric input. works fine, client wants limit input 8 numeric values. there away, using code below restrict 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 in advance.
try this
$(document).ready(function () { $('input.numberinput').bind('keypress', function (e) { if(this.value.length>= 8) { alert('maximum limit 8'); return false; } return !(e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57) && e.which != 46); });
});
Comments
Post a Comment