You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I agree it could be a breaking change...
For now I will create my custom functions lessThanIfOtherNotEmpty; next to lessThanEqualNumberIfOtherNotEmpty to compare float numbers correctly.
One question about my custom methods is if I should create a class (like does .validate-lessThanEqual-blur for each of it).
j.validator.addMethod("lessThanIfOtherNotEmpty",function(val1,element,param){vartarget=j(param);// if (// this.settings.onfocusout &&// target.not(".validate-lessThanIfOtherNotEmpty-blur").length// ) {// target// .addClass("validate-lessThanIfOtherNotEmpty-blur")// .on("blur.validate-lessThanIfOtherNotEmpty", function () {// j(element).valid();// });// }varval2=target.val(),normalizer;if((rules=target.rules())){if(typeofrules.normalizer==="function"){normalizer=rules.normalizer;}elseif(typeofthis.settings.normalizer==="function"){normalizer=this.settings.normalizer;}// If normalizer is defined, then call it to retreive the changed value instead// of using the real one.// Note that `this` in the normalizer is `element`.if(normalizer){val2=normalizer.call(element,val2);// Delete the normalizer from rules to avoid treating it as a pre-defined method.deleterules.normalizer;}}if(val1==""||val2==""){returntrue;}returnval1<val2;},"Please enter a lesser value.");
Your environment
jquery-validate
: v1.19.3Current behavior
When using rule
lessThan
comparing to an empty field, error is triggered.Expected behavior
Error should only be triggered if both fields are populated; user could/should add
required
to the other field if necessary.Live demo
The text was updated successfully, but these errors were encountered: