I used the following code:
<script type="text/javascript">
function validate() {
if ((document.changepass.newpassword.value != '') &&
(document.changepass.retypenewpassword.value ==
document.changepass.newpassword.value)){
document.changepass.retypenewpassword.blur();
document.changepass.submit();
}
}
</script>
<form name="changepass" method="POST" action="changepassword.jsp" onsubmit="return validate();">
<table align="center">
<tr>
<td>New Password:</td>
<td><input type="password" name="newpassword" size="20"
style="width: 145px" maxlength="10"></td>
</tr>
<tr>
<td>Retype New Password:</td>
<td><input type="password" name="retypenewpassword" size="20"
style="width: 144px" maxlength="10"></td>
</tr>
<tr>
<td><input type="submit" value="Change Password" name="operation" ></td>
<td><input type="reset"></td>
</tr>
</table>
</form>
but when I’m giving unmatched entry then also it getting changed.i mean the validate function is not getting called.
plz help
in hope
robin
The
onsubmithandler on your<form>is looking for a return value, but is not given one from yourvalidatefunction. Instead of callingsubmit()in the function, you should return true or false, depending on if the form validates (if the function returnsfalse, that is equivalent toonsubmit="false", which will cancel the submission):