
10/07/2007, 08:29
|
 | Colaborador | | Fecha de Ingreso: febrero-2002 Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 23 años Puntos: 772 | |
Re: Checkbox y textbox Hola Galletero
Prueba este ejemplo:
Código:
<html>
<head>
<meta>
<script type="text/javascript">
function validar(e,obj) {
tecla = (document.all) ? e.keyCode : e.which;
if (tecla==8) return true;
patron =(obj.chk.checked) ? /\d/ : /[A-Za-z\s]/;
te = String.fromCharCode(tecla);
return patron.test(te);
}
</script>
</head>
<body>
<form>
Números: <input type="checkbox" name="chk" />
<input type="text" name="textfield" onkeypress="return validar(event,this.form)" />
</form>
</body>
</html>
Saludos,
Última edición por JavierB; 11/07/2007 a las 04:01 |