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