-1

Hi friends I want to validate password with confirm password in struts through declarative javascript validation but its not working please helpme.

Nilesh Shukla
  • 309
  • 2
  • 5
  • 12

1 Answers1

0

It's not suggested to perform such validations in client side (using javascript). Follow this advice, take the password in the server side and do your validation there.
However, I don't know which kind of validation you are taliking about, if you're looking for a silly password match check, use something like that:

function checkPw(form) {
pw1 = form.pw1.value;
pw2 = form.pw2.value;

if (pw1 != pw2) {
alert ("\nYou did not enter the same new password twice. Please re-enter your password.")
return false;
}
else return true;

for this HTML

<form onSubmit="return checkPw(this)">
<center>
<table border=0>
<tr>
<td>Password:</td><td><input type=text name=pw1 size=10></td>
</tr>
<tr>
<td>Re-enter:</td><td><input type=text name=pw2 size=10></td>
</tr>
<tr>
<td colspan=2 align=center><input type=submit value="Submit!"></td>
</tr>
</table>
</form>

But remember if the security could be involved doing SERVER SIDE CHECK !!!!

Giuseppe Di Federico
  • 3,501
  • 4
  • 20
  • 19