Ver Mensaje Individual
  #5 (permalink)  
Antiguo 11/12/2006, 01:51
f_murciano
 
Fecha de Ingreso: febrero-2004
Mensajes: 157
Antigüedad: 21 años
Puntos: 0
Re: Validar un decimal sin dos comas

Hola,

Muchas gracias por responder JavierB.

Tengo algunos problemillas con las nuevas opciones que pongo en la funcioncita:

Código PHP:
<html>
<
head>
<
script>
    function 
numeros(e,txt) {
        
tecla = (document.all) ? e.keyCode e.which;
            if (
tecla==8) return true//Tecla de retroceso (para poder borrar)
            
if (tecla==35) return true//Tecla Fin
            
if (tecla==36) return true//Tecla Inicio
            
if (tecla==37) return true//Tecla cursor izquierda
            
if (tecla==39) return true//Tecla cursor derecha
            
if (tecla==52) return false//Dólar
            
if (tecla==53) return false//Porcentaje
        
if ((tecla<48 || tecla>57) && tecla!=46 && tecla!=44 ) return false
        
if (tecla == 46 && (txt.indexOf('.')!=-|| txt.indexOf(',')!=-1)) return false;
        if (
tecla == 44 && (txt.indexOf(',')!=-|| txt.indexOf('.')!=-1)) return false;
    }
</script>
</head>
<body>
<input type="text" onKeyPress="return numeros(event,this.value)">
</body>
</html> 
Los nuevos valores que he puesto gracias a los códigos obtenidos con tu código (<input type="text" onkeyup="alert(event.which)">) no funcionan:

Código PHP:
            if (tecla==35) return true//Tecla Fin
            
if (tecla==36) return true//Tecla Inicio
            
if (tecla==37) return true//Tecla cursor izquierda
            
if (tecla==39) return true//Tecla cursor derecha
            
if (tecla==52) return false//Dólar
            
if (tecla==53) return false//Porcentaje 
Con respecto a los carácteres raros sólo son el % y $ los que puedo escribir, tanto en IE como en Firefox.

¿que crees que puede ser?¿por que no me funcionan los cursores y el inicio y fin en Firefox (en IE si funcionan)?

Muchas gracias por todo.

Saludos.