|
133 | 133 | var form = element.closest('form, .validationEngineContainer'), |
134 | 134 | options = (form.data('jqv')) ? form.data('jqv') : $.validationEngine.defaults, |
135 | 135 | valid = methods._validateField(element, options); |
136 | | - } |
137 | 136 | } |
138 | 137 | if(options.onValidationComplete) { |
139 | 138 | // !! ensures that an undefined return is interpreted as return false but allows a onValidationComplete() to possibly return true and have form continue processing |
|
520 | 519 | ++$.validationEngine.fieldIdCounter; |
521 | 520 | } |
522 | 521 |
|
| 522 | + if(field.hasClass(options.ignoreFieldsWithClass)) |
| 523 | + return false; |
| 524 | + |
523 | 525 | if (!options.validateNonVisibleFields && (field.is(":hidden") && !options.prettySelect || field.parent().is(":hidden"))) |
524 | 526 | return false; |
525 | 527 |
|
|
668 | 670 | required = true; |
669 | 671 | } |
670 | 672 | break; |
| 673 | + case "funcCallRequired": |
| 674 | + errorMsg = methods._getErrorMessage(form, field, rules[i], rules, i, options, methods._funcCallRequired); |
| 675 | + if (errorMsg !== undefined) { |
| 676 | + required = true; |
| 677 | + } |
| 678 | + break; |
671 | 679 |
|
672 | 680 | default: |
673 | 681 | } |
|
693 | 701 | break; |
694 | 702 | } |
695 | 703 | } |
| 704 | + |
| 705 | + //funcCallRequired, first in rules, and has error, skip anything else |
| 706 | + if( i==0 && str.indexOf('funcCallRequired')==0 && errorMsg !== undefined ){ |
| 707 | + promptText += errorMsg + "<br/>"; |
| 708 | + options.isError=true; |
| 709 | + field_errors++; |
| 710 | + end_validation=true; |
| 711 | + } |
696 | 712 |
|
697 | 713 | // If it has been specified that validation should end now, break |
698 | 714 | if (end_validation) { |
|
803 | 819 | // Otherwise if we are doing a function call, make the call and return the object |
804 | 820 | // that is passed back. |
805 | 821 | var rule_index = jQuery.inArray(rule, rules); |
806 | | - if (rule === "custom" || rule === "funcCall") { |
| 822 | + if (rule === "custom" || rule === "funcCall" || rule === "funcCallRequired") { |
807 | 823 | var custom_validation_type = rules[rule_index + 1]; |
808 | 824 | rule = rule + "[" + custom_validation_type + "]"; |
809 | 825 | // Delete the rule from the rules array so that it doesn't try to call the |
|
888 | 904 | "minCheckbox": "range-underflow", |
889 | 905 | "equals": "pattern-mismatch", |
890 | 906 | "funcCall": "custom-error", |
| 907 | + "funcCallRequired": "custom-error", |
891 | 908 | "creditCard": "pattern-mismatch", |
892 | 909 | "condRequired": "value-missing" |
893 | 910 | }, |
|
1041 | 1058 | return fn(field, rules, i, options); |
1042 | 1059 |
|
1043 | 1060 | }, |
| 1061 | + _funcCallRequired: function(field, rules, i, options) { |
| 1062 | + return methods._funcCall(field,rules,i,options); |
| 1063 | + }, |
1044 | 1064 | /** |
1045 | 1065 | * Field match |
1046 | 1066 | * |
|
2002 | 2022 | focusFirstField:true, |
2003 | 2023 | // Show prompts, set to false to disable prompts |
2004 | 2024 | showPrompts: true, |
2005 | | - // Should we attempt to validate non-visible input fields contained in the form? (Useful in cases of tabbed containers, e.g. jQuery-UI tabs) |
2006 | | - validateNonVisibleFields: false, |
| 2025 | + // Should we attempt to validate non-visible input fields contained in the form? (Useful in cases of tabbed containers, e.g. jQuery-UI tabs) |
| 2026 | + validateNonVisibleFields: false, |
| 2027 | + // ignore the validation for fields with this specific class (Useful in cases of tabbed containers AND hidden fields we don't want to validate) |
| 2028 | + ignoreFieldsWithClass: 'ignoreMe', |
2007 | 2029 | // Opening box position, possible locations are: topLeft, |
2008 | 2030 | // topRight, bottomLeft, centerRight, bottomRight, inline |
2009 | 2031 | // inline gets inserted after the validated field or into an element specified in data-prompt-target |
|
2075 | 2097 | }}; |
2076 | 2098 | $(function(){$.validationEngine.defaults.promptPosition = methods.isRTL()?'topLeft':"topRight"}); |
2077 | 2099 | })(jQuery); |
2078 | | - |
2079 | | - |
|
0 commit comments