jzaefferer/jquery-validation — Issue #271: required error
Author: Losty
Created: 2011-12-01 16:05:33+00:00
State: open

I found an mistake, then i give an expression or callback for required attribute, other methods forget this param and work incorrect.

For example:
MyField {
required: "#Tmp:checked",
min: 10
}

then element #Tmp is not checked, means that value of MyField can be less then 10, how i understand, but it give an error.

i fixed it like this:

depend: function (param, element) {
this.dependParam = param || this.dependParam;
return this.dependTypes[typeof this.dependParam]
? this.dependTypes[typeof this.dependParam](this.dependParam, element)
: true;
},

dependParam: undefined,

dependTypes: {
"boolean": function (param, element) {
return param;
},
"string": function (param, element) {
return !!$(param, element.form).length;
},
"function": function (param, element) {
return param(element);
}
},

optional: function (element) {
var required = $.validator.methods.required.call(this, $.trim(element.value), element, this.dependParam);

return !required || required == "dependency-mismatch";
}