Issue: When using the submit submission button in jquery, the form will still be submitted when return is false.
WORKAROUND: Use the button buttons instead of the Submit button
<script type= "Text/javascript" src= "Scripts/jquery-2.0.2.js" ></script>
<script type= "Text/javascript" >
function Check () {
var npassword=$ ("#npassword"). Val ();
var npassword2=$ ("#npassword2"). Val ();
if (npassword==null| | npassword== "") {
Alert ("Password cannot be empty!") ");
$ ("#npassword"). focus ();
return false;
} else if (Npassword2!=npassword) {
Alert ("Two times password Inconsistent");
$ ("#npassword2"). attr ("Value", "");
$ ("#npassword2"). focus ();
return false;
}else{
$ ("#form"). Submit ();
}
}
</script>
<body bgcolor= "#E2E4F0" >
<form name= "form" id= "form" action= "selfservice.jsp" method= "POST" >
<input type= "hidden" name= "action" value= "Modpassword"/>
<table border= "2" align= "center" style= "margin:200px 100px 200px 400px" >
<tr>
<td> New Password:</td>
<td><input type= "Password" id= "Npassword" name= "Npassword"/></td>
</tr>
<tr>
<td> Confirm Password:</td>
<td><input type= "Password" id= "Npassword2" name= "Npassword2"/></td>
</tr>
<tr>
<td><input type= "button" value= "submit" check (); " ></td>
<td><input type= "reset" value= "reset" ></td>
</tr>
</table>
</form>
</body>