Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/05/2006, 01:48
Avatar de JavierB
JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 3 meses
Puntos: 772
Hola alays

Creo que lo mas sencillo es hacerlo todo en una sola función. Te pongo un código que funciona en IE y Firefos:
Código:
<html>
<head>
<script type="text/javascript">
function validar(e) {
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla==8) return true;
    if (tecla==13) {
      document.forms[0].submit();
      return false;
    }
    patron = /\d/;
    te = String.fromCharCode(tecla);
    return patron.test(te); 
} 
</script> 
</head>
<body>
<form action="algo.php">
<input type="text" onkeypress="return validar(event)" />
</form>
</body>
</html>
Saludos,