Skip to content

Commit 115e5dd

Browse files
committed
Merge pull request #785 from tomchiverton/patch-1
Add funcCallRequired rule
2 parents 0de6db4 + 3def99c commit 115e5dd

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

js/jquery.validationEngine.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,12 @@
667667
required = true;
668668
}
669669
break;
670+
case "funcCallRequired":
671+
errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._funcCallRequired);
672+
if (errorMsg !== undefined) {
673+
required = true;
674+
}
675+
break;
670676

671677
default:
672678
}
@@ -692,6 +698,14 @@
692698
break;
693699
}
694700
}
701+
702+
//funcCallRequired, first in rules, and has error, skip anything else
703+
if( i==0 && str.indexOf('funcCallRequired')==0 && errorMsg !== undefined ){
704+
promptText += errorMsg + "<br/>";
705+
options.isError=true;
706+
field_errors++;
707+
end_validation=true;
708+
}
695709

696710
// If it has been specified that validation should end now, break
697711
if (end_validation) {
@@ -802,7 +816,7 @@
802816
// Otherwise if we are doing a function call, make the call and return the object
803817
// that is passed back.
804818
var rule_index = jQuery.inArray(rule, rules);
805-
if (rule === "custom" || rule === "funcCall") {
819+
if (rule === "custom" || rule === "funcCall" || rule === "funcCallRequired") {
806820
var custom_validation_type = rules[rule_index + 1];
807821
rule = rule + "[" + custom_validation_type + "]";
808822
// Delete the rule from the rules array so that it doesn't try to call the
@@ -887,6 +901,7 @@
887901
"minCheckbox": "range-underflow",
888902
"equals": "pattern-mismatch",
889903
"funcCall": "custom-error",
904+
"funcCallRequired": "custom-error",
890905
"creditCard": "pattern-mismatch",
891906
"condRequired": "value-missing"
892907
},
@@ -1040,6 +1055,9 @@
10401055
return fn(field, rules, i, options);
10411056

10421057
},
1058+
_funcCallRequired: function(field, rules, i, options) {
1059+
return methods._funcCall(field,rules,i,options);
1060+
},
10431061
/**
10441062
* Field match
10451063
*

0 commit comments

Comments
 (0)