//OTHER METHOD BY CLASS
I share this way of allowing the entry of only numbers through a class, to be able to add them to the inputs.
var keyNoNumbers = [8, 9, 16, 37, 38, 39, 40, 46];
var keyboardRightNumbers = [97, 98, 99, 100, 101, 102, 103, 104, 105];
var generalKeysEnabled = keyNoNumbers.concat(keyboardRightNumbers);
$(".onlyNumbers").on('keydown', function(e){
var str= String.fromCharCode(e.which);
if (!(generalKeysEnabled.includes(e.which))){
if (!(/[0-9]/.test(str))) {
e.preventDefault();
}
}
});