jquery determines if the form form is empty

Source: Internet
Author: User

Function: Use jquery to determine if the form is not filled in, and if it is not filled, block the submission

$ (function () {$ (' form '). Bind (' Submit ', function () {//] bind the form tag to the Submit event Var i=0;      $ ("input"). each (function () {///iterates through the input tag to determine if the content is not filled with Var vl=$ (this). Val ();      if (vl== "") {I=1;    }    });  var t=$ (' textarea '). Val ();    Determine if the textarea label is filled in if (t== ") {i=1;      if (i==1) {//If there is not filled in, then return false to prevent the submission of alert (' Please fill in the information complete ');    return false; }  });});

jquery determines if the form form is empty

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.