Controllo password

pippuccio76

Utente Attivo
21 Lug 2013
27
1
3
Salve ho 2 campi password e controllo password :

Codice:
<tr>
    <td>Password </td>
    <td><input name="pw1" class="ricercamod2" type="password" onblur='check_pw()'  /> <label id="pw1" class="alert"></label></td>
  </tr>

  <tr>
    <td>Ripeti la Password </td>
    <td><input name="pw2" class="ricercamod2" type="password" onblur='check_pw()'  /> <label id="pw2" class="alert"></label></td>
  </tr>

che controllo con il seguente codice js :

Codice:
 var check_pw = function () {
    	
		var pwn = document.form_register_host.pw1.value.length;
		var pw1 = document.form_register_host.pw1.value;
		var pw2 = document.form_register_host.pw2.value;
		
		
		if (pwn<8 || pwn>12) {
			document.getElementById(pw1).innerHTML = '<img src="img/no.png"> La password deve essere compresa tra 8 e 12 caratteri';
			document.form_register_host.pw1.focus();
			pw=0;

		}
		else if (pw1!=pw2) {
				document.getElementById(pw1).innerHTML = '<img src="img/no.png"> Le password non coincidono';
				document.form_register_host.pw1.focus();
				pw=0;

		}
			
		else{
			document.getElementById(pw1).innerHTML = '<img src="img/si.png">';
			pw=1;
				
		}
		check_allok();
		
}

Perchè uscendo dal campo pw1 non ottengo nessuna immagine (in tutti gli altri campi funziona ) dove sbaglio ?
 
Se tu richiami la funzione check_pw la funzione deve avere questa sintassi:

function check_pw (){
resto del codice
}
 

Discussioni simili