Jquery Validate triggers an asynchronous checksum of a single element based on events from other elements

Source: Internet
Author: User

Scene: In a vehicle information management module, and the license plate is the license plate color and license plate number to determine the uniqueness of the license plate information to be required for the unique verification of the license plate.

Asynchronous calibration rules for car grades

1 rules:{2 platenumber:{3 remote:{4URL: ' ${ctx}/bu/vehicleinfo/checkplatenumuniqueness ',5 data:{6Platenumber:function(){7                             return$ ("#plateNumber"). Val ();8                         },9Platecolor:function(){Ten                             return$ ("#plateColor"). Val (); One                         } A                     } -                 } -             } the         }, - messages:{ - platenumber:{ -Remote: ' The same license plate number already exists ' +             } -}

When the license plate color changes, the uniqueness can be verified by triggering the verification rules of the license plate number.

$ ("#plateColor"). Change (function() {    // due to the license plate number and the license plate color to determine the license plate number uniqueness, Therefore, the license plate color changes should also check the car brand unique    $ ("#plateNumber"). Removedata (' Previousvalue ');     var platenum = $ ("#plateNumber"). Val ();     if (Platenum! = ") {        $ (" #plateNumber "). Removedata (' Previousvalue ');        Validator.element ($ ("#plateNumber"));}    );

Here is a problem, that is, the license plate color changes once triggered the uniqueness of the check, and then to change the license plate color can not again trigger the uniqueness of the check,

Then I found the answer here (http://stackoverflow.com/questions/2710548/ how-do-i-use-jquery-validate-remote-validation-on-a-field-that-depends-on-anothe)

The reason is that there will be a cache after the trigger, and you need to call this Removedata method to clean up the cache before triggering again.

Jquery Validate triggers an asynchronous checksum of a single element based on events from other elements

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.