[Resolvido] Tecla TAB só funciona no IE
Ola amigos!
To usando uma função que permiti que o usuario digite somente numeros no campo. Só que a tecla TAB não funciona como faço para libera-la?
<script>
function Numero(e){
navegador = /msie/i.test(navigator.userAgent);
if (navegador)
var tecla = event.keyCode;
else
var tecla = e.which;
if(tecla > 47 && tecla < 58) // numeros de 0 a 9
return true;
else{
if (tecla != 8) // backspace
return false;
else
return true;
}
}
</script>
<input type="text" name="campo" onKeyPress="return Numero(event);">Tentei colocar assim, mas só funcionou no IE no Mozilla não!
<script>
function Numero(e){
navegador = /msie/i.test(navigator.userAgent);
if (navegador)
var tecla = event.keyCode;
else
var tecla = e.which;
if(tecla > 47 && tecla < 58) // numeros de 0 a 9
return true;
else{
if (tecla != 8) // backspace
return false;
else if (tecla == 9) // TAB
return true;
else
return true;
}
}
</script>
<input type="text" name="campo" onKeyPress="return Numero(event);">Também tentei colocar assim e não funcionou no Mozila:
if(tecla > 47 && tecla < 58 || tecla == 9) // numeros de 0 a 9 e TAB
Obrigado!
Discussão (5)
Carregando comentários...