Ver Mensaje Individual
  #8 (permalink)  
Antiguo 16/09/2004, 23:27
kepawe
 
Fecha de Ingreso: agosto-2004
Mensajes: 157
Antigüedad: 20 años, 6 meses
Puntos: 5
Hola DINASEN

He probado este script en Mozilla 1.7 por lo que tambien deberia funcionar en Netscape.
He convertido el numero del teclado en el caracter y luego lo compruebo con
una expresion regular. Espero que te sea util.

Un saludo

<head>

<script language="JavaScript">
<!--
/* Sustituye el valor asignado a mask_string por:

/[^\d]/i para cualquier caracter menos numeros
/[\d\s]/ solo numeros y espacios
/\d/ solo numeros

*/
var nav4plus = window.Event ? true : false;
function acceptChar(evt){
var key = nav4plus ? evt.which : evt.keyCode;
var its_char = String.fromCharCode(key)
if( key == 8){return true}
var mask_string = /[\d\s]/
return mask_string.test(its_char.toString())? true : false



}
//-->
</script>

</head>
<body>

<p><input type="text" name="valor" size="12" maxlength="12"
onKeyPress="return acceptChar(event)"></p>

</body