Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Função apenas números (limita a digitação somente de números em campos "text") colocar em <input type='text' onkeypress='return Apenas_Numeros(event);'>
function Apenas_Numeros(caracter)
{
var nTecla = 0;
if (document.all) {
nTecla = caracter.keyCode;
} else {
nTecla = caracter.which;
}
if ((nTecla> 47 && nTecla <58)
|| nTecla == 8 || nTecla == 127
|| nTecla == 0 || nTecla == 9 // 0 == Tab
|| nTecla == 13) { // 13 == Enter
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.