Ver Mensaje Individual
  #5 (permalink)  
Antiguo 11/04/2009, 15:27
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: Permitir solo cierto caracters en un campo

Probá así:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html>
<
head>
<
meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<
title>Validar entrada de datos</title>
<
script type="text/javascript">
/*---- Créditos: javierB - http://www.telefonica.net/web2/blas-mar/validarformu.html ----*/
function validar(e) { 
    
tecla = (document.all) ? e.keyCode e.which
    if (
tecla==8) return true
    
patron =/[0-9.s]/; 
    
te String.fromCharCode(tecla);
    return 
patron.test(te); 

</script>
</head>

<body>
<form name="formulario">
  <input type="text" name="nombre" onkeypress="return validar(event)" onpaste="return false;" />
</form>

</body>
</html>