Ver Mensaje Individual
  #4 (permalink)  
Antiguo 26/01/2005, 21:09
PHP Novatillo
 
Fecha de Ingreso: enero-2005
Mensajes: 92
Antigüedad: 19 años, 3 meses
Puntos: 0
Mira, en el ejemplo, en el script se recibe el contenido de lo que escribió en la variable tx, y la propiedad length obtiene el numero de caracteres de la variable, podrias poner:

Código:
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript" type="text/javascript">
function valida(tx) 
{ 
	var nMay = 0, nMin = 0, nNum = 0 
	var t1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 
	var t2 = "abcdefghijklmnopqrstuvwxyz" 
	var t3 = "0123456789"
                   if (tx.length < 5) {
                            alert("Su password, debe tener almenos 5 letras");
                   } else {
                          //Aqui continua si la variable ya tiene mas de 5 letras
               	for (i=0;i<tx.length;i++) { 
			if ( t1.indexOf(tx.charAt(i)) != -1 ) {nMay++} 
			if ( t2.indexOf(tx.charAt(i)) != -1 ) {nMin++} 
			if ( t3.indexOf(tx.charAt(i)) != -1 ) {nNum++} 
		} 
		if ( nMay>0 && nMin>0 && nNum>0 ) 
		form.submit()
		else 
		{ alert("Su password debe contener minimo 5 caracteres alfanumericos"); form.texto1.focus(); return; }
}
} 
</script>
</head> 
<body> 
<form name="form" action="algo.php" method="post"> 
<input type="password" name="texto1"> 
<input type="button" value="Validar" onClick="valida(this.form.texto1.value)"> 
</form> 
</body>
</html>