I have a function in JavaScript to fill out forms that allows me to only enter numbers in a text box.
The problem is that it only works on computers and not on mobile devices.
function validarNumero(e) {
tecla = (document.all) ? e.keyCode : e.which;
if (tecla==8) return true;
patron =/[0-9]/;
te = String.fromCharCode(tecla);
return patron.test(te);
}
And in the HTML code part
<input type="text" id="txtNumero" maxlength="10" onkeypress="return validarNumero(event)">