i am trying to create an input field where the user can only type in numbers. this function is already working almost fine for me:
$(\'#p_first\').k
With a key event, use event.key to get the actual value. To check if integer:
event.key
isFinite(event.key);
An easier HTML solution would be to use the number type input. It restricts to only numbers (kind of).
number
Either way, you should clean all user input with:
string.replace(/[^0-9]/g,'');