|
667 | 667 | required = true; |
668 | 668 | } |
669 | 669 | 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; |
670 | 676 |
|
671 | 677 | default: |
672 | 678 | } |
|
692 | 698 | break; |
693 | 699 | } |
694 | 700 | } |
| 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 | + } |
695 | 709 |
|
696 | 710 | // If it has been specified that validation should end now, break |
697 | 711 | if (end_validation) { |
|
802 | 816 | // Otherwise if we are doing a function call, make the call and return the object |
803 | 817 | // that is passed back. |
804 | 818 | var rule_index = jQuery.inArray(rule, rules); |
805 | | - if (rule === "custom" || rule === "funcCall") { |
| 819 | + if (rule === "custom" || rule === "funcCall" || rule === "funcCallRequired") { |
806 | 820 | var custom_validation_type = rules[rule_index + 1]; |
807 | 821 | rule = rule + "[" + custom_validation_type + "]"; |
808 | 822 | // Delete the rule from the rules array so that it doesn't try to call the |
|
887 | 901 | "minCheckbox": "range-underflow", |
888 | 902 | "equals": "pattern-mismatch", |
889 | 903 | "funcCall": "custom-error", |
| 904 | + "funcCallRequired": "custom-error", |
890 | 905 | "creditCard": "pattern-mismatch", |
891 | 906 | "condRequired": "value-missing" |
892 | 907 | }, |
|
1040 | 1055 | return fn(field, rules, i, options); |
1041 | 1056 |
|
1042 | 1057 | }, |
| 1058 | + _funcCallRequired: function(field, rules, i, options) { |
| 1059 | + return methods._funcCall(field,rules,i,options); |
| 1060 | + }, |
1043 | 1061 | /** |
1044 | 1062 | * Field match |
1045 | 1063 | * |
|
0 commit comments