I have this code to filter a form field on a mobile device so that only numeric phone numbers are allowed:
$( document ).on( "keypress", ".numeric_only", function(e) {
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
return false;
}
});
The problem is, even with this it still allows people to enter characters like -
or .
especially on Android ..even if I allow only the numerical tel
keyboard.
What am I doing wrong?