Created
October 18, 2012 16:54
-
-
Save Vampre/3913238 to your computer and use it in GitHub Desktop.
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);'>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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