Roy Harper
Coder
I recently noticed that my website input validation of prevention of letter typing is not working on mobile. I can freely type anything on the input. While on desktop, it works just fine. What should I do?
JavaScript:
function validateNumber(event) {
var key = event ? event.keyCode : event.which;
if (event.keyCode === 8 || event.keyCode === 46) {
return true;
} else if (key < 48 || key > 57) {
return false;
} else {
return true;
}
}