|
668 | 668 | required = true;
|
669 | 669 | }
|
670 | 670 | break;
|
| 671 | + case "funcCallRequired": |
| 672 | + errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._funcCallRequired); |
| 673 | + if (errorMsg !== undefined) { |
| 674 | + required = true; |
| 675 | + } |
| 676 | + break; |
671 | 677 |
|
672 | 678 | default:
|
673 | 679 | }
|
|
693 | 699 | break;
|
694 | 700 | }
|
695 | 701 | }
|
| 702 | + |
| 703 | + //funcCallRequired, first in rules, and has error, skip anything else |
| 704 | + if( i==0 && str.indexOf('funcCallRequired')==0 && errorMsg !== undefined ){ |
| 705 | + promptText += errorMsg + "<br/>"; |
| 706 | + options.isError=true; |
| 707 | + field_errors++; |
| 708 | + end_validation=true; |
| 709 | + } |
696 | 710 |
|
697 | 711 | // If it has been specified that validation should end now, break
|
698 | 712 | if (end_validation) {
|
|
803 | 817 | // Otherwise if we are doing a function call, make the call and return the object
|
804 | 818 | // that is passed back.
|
805 | 819 | var rule_index = jQuery.inArray(rule, rules);
|
806 |
| - if (rule === "custom" || rule === "funcCall") { |
| 820 | + if (rule === "custom" || rule === "funcCall" || rule === "funcCallRequired") { |
807 | 821 | var custom_validation_type = rules[rule_index + 1];
|
808 | 822 | rule = rule + "[" + custom_validation_type + "]";
|
809 | 823 | // Delete the rule from the rules array so that it doesn't try to call the
|
|
888 | 902 | "minCheckbox": "range-underflow",
|
889 | 903 | "equals": "pattern-mismatch",
|
890 | 904 | "funcCall": "custom-error",
|
| 905 | + "funcCallRequired": "custom-error", |
891 | 906 | "creditCard": "pattern-mismatch",
|
892 | 907 | "condRequired": "value-missing"
|
893 | 908 | },
|
|
1041 | 1056 | return fn(field, rules, i, options);
|
1042 | 1057 |
|
1043 | 1058 | },
|
| 1059 | + _funcCallRequired: function(field, rules, i, options) { |
| 1060 | + return methods._funcCall(field,rules,i,options); |
| 1061 | + }, |
1044 | 1062 | /**
|
1045 | 1063 | * Field match
|
1046 | 1064 | *
|
|
0 commit comments