Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/12/2012, 17:16
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Quitar foco luego de pulsar una tecla

fijate asi
Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. <html lang="es-ar">
  3. <meta charset="utf-8" />
  4. <title>Aceptar solo rango de números desde teclado</title>
  5. </head>
  6. <script type="text/javascript">
  7. //<![CDATA[
  8.  
  9. function verifica(campo){
  10. var elcampo = document.getElementById(campo);
  11. var valor = parseInt(elcampo.value);
  12.     if(valor == 1){
  13.     document.getElementById("otrocampo").focus();
  14.     return false;
  15.     }
  16.    
  17.     if(valor >= 2 && valor <= 6){
  18.     alert("hay que ingresar una observación");
  19.     document.getElementById("otrocampo").focus();
  20.     return false;
  21.     }
  22.  
  23. }
  24. function validar(e){
  25. var expresion=/[1-6\b]/;
  26. return expresion.test(String.fromCharCode(e.which));
  27. }
  28. //]]>
  29.  <input type="text" id="descarte" name="descarte" onkeypress="return validar(event)" onkeyup="verifica(this.id)" maxlength="1"/>
  30.  <input type="text"  id="otrocampo" />
  31. </body>
  32. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.