Skip to content

Commit 2debd25

Browse files
committed
make so that you can use custom options when you use the 'validate' method! $(this).validationEngine('validate',{promptPosition: 'centerRight'}); for example
1 parent 60cb1ae commit 2debd25

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
@@ -518,7 +522,7 @@
518522

519523
if(field.hasClass(options.ignoreFieldsWithClass))
520524
return false;
521-
525+
522526
if (!options.validateNonVisibleFields && (field.is(":hidden") && !options.prettySelect || field.parent().is(":hidden")))
523527
return false;
524528

@@ -698,7 +702,7 @@
698702
break;
699703
}
700704
}
701-
705+
702706
//funcCallRequired, first in rules, and has error, skip anything else
703707
if( i==0 && str.indexOf('funcCallRequired')==0 && errorMsg !== undefined ){
704708
promptText += errorMsg + "<br/>";
@@ -2020,7 +2024,7 @@
20202024
// Should we attempt to validate non-visible input fields contained in the form? (Useful in cases of tabbed containers, e.g. jQuery-UI tabs)
20212025
validateNonVisibleFields: false,
20222026
// 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',
20242028
// Opening box position, possible locations are: topLeft,
20252029
// topRight, bottomLeft, centerRight, bottomRight, inline
20262030
// inline gets inserted after the validated field or into an element specified in data-prompt-target

0 commit comments

Comments
 (0)