1
I have this input
where I own a function
, just to accept numbers by typing it works, however I would like to put this function
in the onpaste
also, if I do putting onpaste="return SomenteNumeros(event)"
, does not work. Does not recognize, it lets pass letters, dots, commas , etc.
It would be necessary to put in the onpaste
, to validate this information.
function SomenteNumeros(event) {
if (event.keyCode < 48 || event.keyCode > 57)
return false;
}
<input class="form-control" maxlength="8" placeholder="Somente números." OnKeyPress="return SomenteNumeros(event)">
The way it is already blocks collage of non-numeric characters.
– Augusto Vasques