Solutions for jquery-easyui mandatory field hiding problems

Source: Internet
Author: User
Using jquery-easyui to create a user interface, the required items are simple. You only need a simple attribute data-options & quot; required: true & quot; to change an input to a required item. However, the actual problem is that, in some cases, even if the mandatory items are hidden, they still cannot be submitted. When you submit the file, you can use jquery-easyui to create a user interface. The required items are very simple, you only need a simple attribute data-options = "required: true" to change an input to a mandatory input. However, the actual problem is that, in some cases, even if the mandatory items are hidden, they still cannot be submitted. When the submission is made, the mandatory items are not input !! The jquery-easyui method is to remove the mandatory items if hidden. That is, the following code is used. [Javascript] $ ('# DrpHA'). combobox ({required: false}); however, if you want to hide the required items, you do not need to enter them. Can I modify the source code of jquery-easyui and modify it for verification. So we started to study the source code. Since it is verified upon submission, I guess there should be code when submitting the form. In jquery. form. js knows the following lines of code: [javascript] function validate (target) {if ($. fn. validatebox) {var t = $ (target); t. find ('. validatebox-text: not (: disabled )'). validatebox ('validate'); var invalidbox = t. find ('. validatebox-invalid '); invalidbox. filter (': not (: disabled): first '). focus (); return invalidbox. length = 0;} return true;} after testing, the submission was unsuccessful. It is indeed these lines of code. Modify it as follows. [Javascript] function validate (target) {if ($. fn. validatebox) {var t = $ (target); t. find ('. validatebox-text: not (: disabled )'). validatebox ('validate'); // var invalidbox = t. find ('. validatebox-invalid '); var invalidbox2 = t. find ('. validatebox-invalid '). find (': visible'); // alert (invalidbox2.length); invalidbox2.filter (': not (: disabled): first '). focus (); return invalidbox2.length = 0;} return true;} Finally, modify the above Code in jquery. easyui. min. js. [Javascript] function _ 3d6 (_ 3dc) {if ($. fn. validatebox) {var t = $ (_ 3dc); t. find (". validatebox-text: not (: disabled )"). validatebox ("validate"); // var _ 3dd = t. find (". validatebox-invalid "); var invalidbox2 = t. find ('. validatebox-invalid '). find (': visible'); alert (invalidbox2.length); // _ 3dd. filter (": not (: disabled): first "). focus (); invalidbox2.filter (": not (: disabled): first "). focus (); return invalidbox2.length = 0 ;}
Related Article

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.