Ver Mensaje Individual
  #6 (permalink)  
Antiguo 31/05/2006, 16:44
Avatar de Cap.Buscapina
Cap.Buscapina
 
Fecha de Ingreso: octubre-2004
Ubicación: Argentina
Mensajes: 836
Antigüedad: 20 años, 5 meses
Puntos: 4
con deteccion de la tecla:
Cita:
<html>
<head>
</head>
<script>
function LP_data(e){
key=(document.all) ? e.keyCode : e.which;
if (key < 48 || key > 57){
alert("solo se pueden ingresar numeros");
return false;
}
return true;
}//fin funcion
</script>
<body>
<form>
<input type="text" onkeypress="return LP_data(event)"></form>
</body>
</html>

o bien con expreciones regulares:

Cita:
<html>
<head>
</head>
<script>
function LP_data(v){
patron=/[^0-9\.]/;
v.value=v.value.replace(patron,"");
}
</script>
<body>
<form>
<input type="text" onkeyup="return LP_data(this)"></form>
</body>
</html>
saludos
__________________
by Capitán Buscapina
.