Skip to content

Commit a533cf7

Browse files
committed
Merge pull request #826 from filipac/master
make so that you can use custom options when you use the 'validate' method
2 parents a25545f + 2debd25 commit a533cf7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

js/jquery.validationEngine.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@
101101
*
102102
* @return true if the form validates, false if it fails
103103
*/
104-
validate: function() {
104+
validate: function(userOptions) {
105105
var element = $(this);
106106
var valid = null;
107+
var options;
107108

108109
if (element.is("form") || element.hasClass("validationEngineContainer")) {
109110
if (element.hasClass('validating')) {
@@ -112,7 +113,10 @@
112113
return false;
113114
} else {
114115
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');
116120
var valid = methods._validateFields(this);
117121

118122
// If the form doesn't validate, clear the 'validating' class before the user has a chance to submit again
@@ -536,7 +540,7 @@
536540

537541
if(field.hasClass(options.ignoreFieldsWithClass))
538542
return false;
539-
543+
540544
if (!options.validateNonVisibleFields && (field.is(":hidden") && !options.prettySelect || field.parent().is(":hidden")))
541545
return false;
542546

@@ -716,7 +720,7 @@
716720
break;
717721
}
718722
}
719-
723+
720724
//funcCallRequired, first in rules, and has error, skip anything else
721725
if( i==0 && str.indexOf('funcCallRequired')==0 && errorMsg !== undefined ){
722726
promptText += errorMsg + "<br/>";
@@ -2039,7 +2043,7 @@
20392043
// Should we attempt to validate non-visible input fields contained in the form? (Useful in cases of tabbed containers, e.g. jQuery-UI tabs)
20402044
validateNonVisibleFields: false,
20412045
// ignore the validation for fields with this specific class (Useful in cases of tabbed containers AND hidden fields we don't want to validate)
2042-
ignoreFieldsWithClass: 'ignoreMe',
2046+
ignoreFieldsWithClass: 'ignoreMe',
20432047
// Opening box position, possible locations are: topLeft,
20442048
// topRight, bottomLeft, centerRight, bottomRight, inline
20452049
// inline gets inserted after the validated field or into an element specified in data-prompt-target

0 commit comments

Comments
 (0)