I hava a remote validator setup like so
remote: {
type: "POST",
url: "/some/url",
data: {
value: function() {
return $("#field").val();
},
bypass: function() {
if ($("input:radio[name=toggleBypass]:checked").val() == "yes"){
return "yes";
}
return "no";
}
}
}
If bypass is "yes", the ajax always returns true.
It works on blur and on submit, but if I reset the radio button values then submit, it doesn't revalidate.
For example,
Any ideas how I can get it to work properly?
If you look at line 897 in jquery.validate.js, you'll see an optimization:
if ( previous.old !== value ) {
This line prevents a new validation if the field's value hasn't changed. And since you're using validate().element()
, it only checks that field, not the whole form, so it doesn't detect the change in toggleBypass.
Either remove this check from the jquery.validate source, or check the whole form, not just that field.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With