Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/06/2002, 01:10
Avatar de TomaHawkk
TomaHawkk
 
Fecha de Ingreso: diciembre-2001
Ubicación: España
Mensajes: 422
Antigüedad: 23 años, 5 meses
Puntos: 1
Re: problema de variables numericas y de texto

Hola!

Yo lo que hago es no dejar que el usuario introduzca letras en la caja de texto mediante JavaScript,

aquí te dejo el ejemplo:

Código:
<head>
<script language="JavaScript">
<!--
var nav4 = window.Event ? true : false;
function acceptNum(evt){	
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
var key = nav4 ? evt.which : evt.keyCode;	
return (key <= 13 || (key >= 48 && key <= 57));
}
//-->
</script>

</head>
<body>
Prueba a introducir caracteres en la caja de texto. Solo te dejará numeros!<br>
<p><input type="text" name="valor" size="12" maxlength="12"
onKeyPress="return acceptNum(event)"></p>
</body>
Saludos.