jquery is using the submit issue in form, not resolved

Source: Internet
Author: User

  $ ("#login_btn"). Click (function () {Type is the button under Submit    if ($ ("#id_password"). Val (). length = = 0) {// Verify that password is empty      $ (' form '). Submit (function () {        alert ("1")        return false;      });    else if ($ ("#vali"). val ()! = code) {//Verify that the code is correct      $ (' form '). Submit (function () {        alert ("2")        return false;      });    }else{      $ (' form '). Submit (function () {        alert ("3")        return true;}      );    }  );
When the test is found, when the password is empty, the popup 1, and then click once. Popped two times 1. Click again, pop up three 1; Enter password. Click again to find pop-up 1, 1. 1. 2, looking for a long time do not know why
Change strategy later
<pre name= "code" class= "HTML" >$ (' form '). Submit (function () {    var b = true;    if ($ ("#id_password"). Val (). length = = 0) {      $ ("#verify"). html (' <div class= ' alert alert-error ' > Please enter your password!</ Div> '). Show ();      b = false;    } else if ($ ("#vali"). val ()! = code) {      $ ("#verify"). html (' <div class= ' alert alert-error ' > CAPTCHA input Error!</div> '). Show ();      b = false;    } else{      B = true;    }      return b;  });
So that I can, I don't know why ~ ~ ~ Ask for answers


Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

jquery is using the submit issue in form, not resolved

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.