How to make input numeric only in jQuery

To make input numeric only in jQuery you can use the following snippet.

Sample jQuery

$('input.numbersOnlyinput').bind('keypress', function(input) {   
    return (input.which === 0 || input.which === 8 || (input.shiftKey === false && (input.which < 58 && input.which > 47))) ? true : false;   
}

Please Share us:
Please rate this snippet

2 thoughts on “How to make input numeric only in jQuery

Leave a Reply