Created
November 4, 2015 17:22
-
-
Save renoirtech/dc6e2bf94e23f6bf9ef2 to your computer and use it in GitHub Desktop.
Função para verificar se um campo possui apenas números.
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 teclaPermitida(event) { | |
if ((event.keyCode == 8) || (event.keyCode == 46) || (event.keyCode == 9) || (event.keyCode == 37) || (event.keyCode == 39) || (event.keyCode == 116) || (event.keyCode == 16) || (event.keyCode == 36)) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function sonum(event) { | |
if (window.event) var event = window.event; | |
//alert(event.keyCode); | |
var tecla = event.keyCode; | |
//remapeia o codigo das teclas do teclado numerico | |
if ((tecla >= 96) && (tecla <= 105)) { | |
var tecla = tecla - 48; | |
} | |
if (teclaPermitida(event)) return true; | |
if ((tecla < 48) || (tecla > 57) && (tecla != "0") && (tecla != 8)) { | |
//event.keyCode = 0; | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment