Below is the function I use to only number, delete, backspace and tap are allow.
$(document).on("keydown", "#number", function(e) { var key = e.charCode || e.keyCode || 0; if (key == 8 || key == 9 || key == 13 || key == 46 || key == 110 || key == 190 || (key >= 35 && key <= 40) ||(key >= 48 && key <= 57) || (key >= 96 && key <= 105)) { return; } else { return false; } });