jquery Validation form Submission Form

Source: Internet
Author: User

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>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.