|
101 | 101 | * |
102 | 102 | * @return true if the form validates, false if it fails |
103 | 103 | */ |
104 | | - validate: function() { |
| 104 | + validate: function(userOptions) { |
105 | 105 | var element = $(this); |
106 | 106 | var valid = null; |
| 107 | + var options; |
107 | 108 |
|
108 | 109 | if (element.is("form") || element.hasClass("validationEngineContainer")) { |
109 | 110 | if (element.hasClass('validating')) { |
|
112 | 113 | return false; |
113 | 114 | } else { |
114 | 115 | element.addClass('validating'); |
115 | | - var options = element.data('jqv'); |
| 116 | + if(userOptions) |
| 117 | + options = methods._saveOptions(element, userOptions); |
| 118 | + else |
| 119 | + options = element.data('jqv'); |
116 | 120 | var valid = methods._validateFields(this); |
117 | 121 |
|
118 | 122 | // If the form doesn't validate, clear the 'validating' class before the user has a chance to submit again |
|
518 | 522 |
|
519 | 523 | if(field.hasClass(options.ignoreFieldsWithClass)) |
520 | 524 | return false; |
521 | | - |
| 525 | + |
522 | 526 | if (!options.validateNonVisibleFields && (field.is(":hidden") && !options.prettySelect || field.parent().is(":hidden"))) |
523 | 527 | return false; |
524 | 528 |
|
|
698 | 702 | break; |
699 | 703 | } |
700 | 704 | } |
701 | | - |
| 705 | + |
702 | 706 | //funcCallRequired, first in rules, and has error, skip anything else |
703 | 707 | if( i==0 && str.indexOf('funcCallRequired')==0 && errorMsg !== undefined ){ |
704 | 708 | promptText += errorMsg + "<br/>"; |
|
2020 | 2024 | // Should we attempt to validate non-visible input fields contained in the form? (Useful in cases of tabbed containers, e.g. jQuery-UI tabs) |
2021 | 2025 | validateNonVisibleFields: false, |
2022 | 2026 | // ignore the validation for fields with this specific class (Useful in cases of tabbed containers AND hidden fields we don't want to validate) |
2023 | | - ignoreFieldsWithClass: 'ignoreMe', |
| 2027 | + ignoreFieldsWithClass: 'ignoreMe', |
2024 | 2028 | // Opening box position, possible locations are: topLeft, |
2025 | 2029 | // topRight, bottomLeft, centerRight, bottomRight, inline |
2026 | 2030 | // inline gets inserted after the validated field or into an element specified in data-prompt-target |
|
0 commit comments