Ciao a tutti ho un problema
Ho una semplice form per il cambio password e prima di mandare i dati alla servlet faccio 2 controlli:
1 Se uno delle 2 password ha valore nullo
2 Se le 2 password sono uguali
Vorrei che premendo il botone di submit della form se uno dei 2 check non è rispettato i dati non arrivano alla servlet e mentre per il secondo controllo funziona per il primo non ci riesco
potete aiutarmi???
Grazie
codice:
html
<form method="POST" action="ChangePswServlet">
<table border="0" >
<tr><td>Name</td><td><input type="text" name="name" disabled="disabled" value=<%out.print(name);%>><input type="text" name="r_id" style="display:none;visibility:hidden;" value=<%out.print(resource_id);%>></td></tr>
<tr><td>Surname</td><td><input type="text" name="surname" disabled="disabled" value=<%out.print(surname);%>></td></tr>
<tr><td>Password</td><td><input type="password" name="psw" id="changePwd"></td></tr>
<tr><td>Confirm Password</td><td><input type="password" id="changeConfPwd" name="confpsw" onblur="confChangePwd(this.value)"></td></tr>
<tr><<td>email</td><td><input type="text" name="email" disabled="disabled" value=<%out.print(email);%>></td></tr>
<tr><td><button type="reset">RESET</button></td><td><button type="submit">UPDATE</button></td></tr>
</table>
</form>
codice:
js
function confChangePwd(elem){
var pwd=document.getElementById("changePwd").value;
if (((pwd == null)||(pwd.length <= 0)) || ((elem == null)||(elem.length <= 0))){
alert("passwords null !");
document.getElementById("changePwd").value="";
document.getElementById("changeConfPwd").value="";
return false;
}
if(pwd != elem){
alert("different passwords !");
document.getElementById("changePwd").value="";
document.getElementById("changeConfPwd").value="";
}
}