Text box that allows only numbers using JQuery
below code will allows text box to enter numerics only
To use this you need use numaric as class element as shown below
$(".numeric").keydown(function(event) {
// Allow only backspace and delete
if ( event.keyCode == 46 || event.keyCode == 8 ) {
// let it happen, don't do anything
}
else {
// Ensure that it is a number and stop the keypress
if (event.keyCode 57 ) {
event.preventDefault();
}
}
});
Comments
Post a Comment