Ver Mensaje Individual
  #2 (permalink)  
Antiguo 21/01/2013, 14:21
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: tab javascrip en mozilla

como se supone que estás usando esa validación? y que tiene de particular la tecla tab en firefox?, cuando presionas tab dentro de un campo de texto te saca del campo.
Si querés validar con un evento del teclado un float tenés que comparar contra el valor del campo de texto.
Yo uso esto
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  5. <title>validar número, entero o float</title>
  6. <script type="text/javascript">
  7. //<![CDATA[
  8. var textoactual = "";
  9. function validar(campo,e){
  10. var elcampo = document.getElementById(campo);
  11. e = (e) ? e : ((event) ? event : null);
  12. var version = (e.target) ? e.target : ((e.srcElement)?e.srcElement : null );
  13. var teclaNum = e.keyCode;
  14. if(teclaNum !== 9){
  15. if((!validarNumero(elcampo.value))||(elcampo.value == "")){
  16. if(teclaNum !== 8){
  17. elcampo.value = textoactual;
  18. }
  19. elcampo.focus();
  20. }else{
  21. textoactual = document.getElementById(campo).value;
  22. } // fin valida num
  23. } // fin detectar tecla
  24. } // fin función
  25.  
  26. function validarNumero(input){
  27. return (!isNaN(input)&&parseInt(input)==input)||(!isNaN(input)&&parseFloat(input)==input);
  28. }
  29. //]]>
  30. </head>
  31. <form action="#">
  32. <input type="text" id="precio" name="precio" value="" onkeyup="validar(this.id,event);" /><br />
  33. </form>
  34. <div id="mensaje"></div>
  35. </body>
  36. </html>
Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.