Ver Mensaje Individual
  #2 (permalink)  
Antiguo 08/12/2006, 03:36
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
Re: Validar un decimal sin dos comas

Hola f_murciano

Código PHP:
<html>
<
head>
<
script>
    function 
numeros(e,txt) {
        
tecla = (document.all) ? e.keyCode e.which;
        if ((
tecla<48 || tecla>57) && tecla!=46) return false
        
if (tecla == 46 && txt.indexOf('.')!=-1) return false;
    }
</script>
</head>
<body>
<input type="text" onKeyPress="return numeros(event,this.value)">
</body>
</html> 
Por cierto, deberías añadir algo para que se pueda usar la tecla de retroceso.

Saludos,