Skip to content

Commit 7a76e84

Browse files
committed
changed $(node) to node inside the validation class
1 parent 6bc4e6d commit 7a76e84

File tree

1 file changed

+39
-34
lines changed

1 file changed

+39
-34
lines changed

jquery.validation.js

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -334,17 +334,17 @@
334334
'node': node,
335335
'function': 'delegateDynamicValidation()',
336336
'arguments': JSON.stringify(options),
337-
'message': 'OK - Dynamic Validation activated on ' + $(node).length + ' form(s)'
337+
'message': 'OK - Dynamic Validation activated on ' + node.length + ' form(s)'
338338
});
339339
// {/debug}
340340

341-
if ( !$(node).find('[' + _data.validation + '],[' + _data.regex + ']')[0]) {
341+
if ( !node.find('[' + _data.validation + '],[' + _data.regex + ']')[0]) {
342342

343343
// {debug}
344344
options.debug && window.Debug.log({
345345
'node': node,
346346
'function': 'delegateDynamicValidation()',
347-
'arguments': '$(node).find([' + _data.validation + '],[' + _data.regex + '])',
347+
'arguments': 'node.find([' + _data.validation + '],[' + _data.regex + '])',
348348
'message': 'ERROR - [' + _data.validation + '] not found'
349349
});
350350
// {/debug}
@@ -359,7 +359,7 @@
359359
}
360360

361361
$.each(
362-
$(node).find('[' + _data.validation + '],[' + _data.regex + ']'),
362+
node.find('[' + _data.validation + '],[' + _data.regex + ']'),
363363
function (index, input) {
364364

365365
$(input).unbind(event).on(event, function (e) {
@@ -395,14 +395,6 @@
395395
)
396396
}
397397

398-
var _typeWatch = (function(){
399-
var timer = 0;
400-
return function(callback, ms){
401-
clearTimeout (timer);
402-
timer = setTimeout(callback, ms);
403-
}
404-
})();
405-
406398
/**
407399
* Delegates the submit validation on data-validation and data-validation-regex attributes based on trigger.
408400
* Note: Disable the form submit function so the callbacks are not by-passed
@@ -418,17 +410,17 @@
418410
'node': node,
419411
'function': 'delegateValidation()',
420412
'arguments': JSON.stringify(options),
421-
'message': 'OK - Validation activated on ' + $(node).length + ' form(s)'
413+
'message': 'OK - Validation activated on ' + node.length + ' form(s)'
422414
});
423415
// {/debug}
424416

425-
if (!$(node).find(options.submit.settings.button)[0]) {
417+
if (!node.find(options.submit.settings.button)[0]) {
426418

427419
// {debug}
428420
options.debug && window.Debug.log({
429421
'node': node,
430422
'function': 'delegateDynamicValidation()',
431-
'arguments': '$(node).find(' + options.submit.settings.button + ')',
423+
'arguments': 'node.find(' + options.submit.settings.button + ')',
432424
'message': 'ERROR - ' + options.submit.settings.button + ' not found'
433425
});
434426
// {/debug}
@@ -437,8 +429,8 @@
437429

438430
}
439431

440-
$(node).on("submit", false );
441-
$(node).find(options.submit.settings.button).unbind(event).on(event, function (e) {
432+
node.on("submit", false);
433+
node.find(options.submit.settings.button).unbind(event).on(event, function (e) {
442434

443435
e.preventDefault();
444436

@@ -484,7 +476,7 @@
484476
var isValid = true;
485477

486478
$.each(
487-
$(node).find('[' + _data.validation + '],[' + _data.regex + ']'),
479+
node.find('[' + _data.validation + '],[' + _data.regex + ']'),
488480
function (index, input) {
489481

490482
if ($(this).is(':disabled')) {
@@ -733,7 +725,7 @@
733725
// Compare Field values
734726
if (isNaN(compared)) {
735727

736-
comparedValue = $(node).find('[name="' + compared + '"]').val();
728+
comparedValue = node.find('[name="' + compared + '"]').val();
737729
if (!comparedValue) {
738730

739731
// {debug}
@@ -817,7 +809,7 @@
817809
return false;
818810
}
819811

820-
input = $(node).find('[name="' + inputName + '"]');
812+
input = node.find('[name="' + inputName + '"]');
821813

822814
label = null;
823815

@@ -839,15 +831,15 @@
839831

840832
if (group) {
841833

842-
groupInput = $(node).find('[name="' + inputName + '"]');
843-
label = $(node).find('[id="' + group + '"]');
834+
groupInput = node.find('[name="' + inputName + '"]');
835+
label = node.find('[id="' + group + '"]');
844836

845837
if (label[0]) {
846838
label.addClass(options.submit.settings.errorClass);
847839
errorContainer = label;
848840
}
849841

850-
//$(node).find('[' + _data.group + '="' + group + '"]').addClass(options.submit.settings.errorClass)
842+
//node.find('[' + _data.group + '="' + group + '"]').addClass(options.submit.settings.errorClass)
851843

852844
} else {
853845

@@ -860,7 +852,7 @@
860852
inputId = input.attr('id');
861853

862854
if (inputId) {
863-
label = $(node).find('label[for="' + inputId + '"]')[0];
855+
label = node.find('label[for="' + inputId + '"]')[0];
864856
}
865857

866858
if (!label) {
@@ -876,7 +868,7 @@
876868
if (options.submit.settings.display === 'inline') {
877869
errorContainer = errorContainer || input.parent();
878870
} else if (options.submit.settings.display === 'block') {
879-
errorContainer = $(node);
871+
errorContainer = node;
880872
}
881873

882874
// Prevent double error list if the previous one has not been cleared.
@@ -990,7 +982,7 @@
990982
} else {
991983

992984
if (!input) {
993-
input = $(node).find('[name="' + inputName + '"]');
985+
input = node.find('[name="' + inputName + '"]');
994986

995987
if (!input[0]) {
996988

@@ -1022,18 +1014,20 @@
10221014
errors = [];
10231015
window.Validation.hasScrolled = false;
10241016

1025-
$(node).find('[' + _data.errorList + ']').remove();
1026-
$(node).find('.' + options.submit.settings.errorClass).removeClass(options.submit.settings.errorClass);
1017+
node.find('[' + _data.errorList + ']').remove();
1018+
node.find('.' + options.submit.settings.errorClass).removeClass(options.submit.settings.errorClass);
10271019

10281020
}
10291021

10301022
/**
10311023
* Submits the form once it succeeded the validation process.
1032-
* Note: This function will be overridden if "options.submit.settings.onSubmit" is defined
1024+
* Note:
1025+
* - This function will be overridden if "options.submit.settings.onSubmit" is defined
1026+
* - The node can't be submitted by jQuery since it has been disabled, use the form native submit function instead
10331027
*/
10341028
function submitForm () {
10351029

1036-
node.submit();
1030+
node[0].submit()
10371031

10381032
}
10391033

@@ -1055,7 +1049,7 @@
10551049
value = ($(input).is(':checked')) ? 1 : '';
10561050
break;
10571051
case 'radio':
1058-
value = $(node).find('input[name="' + $(input).attr('name') + '"]:checked').val() || '';
1052+
value = node.find('input[name="' + $(input).attr('name') + '"]:checked').val() || '';
10591053
break;
10601054
default:
10611055
value = $(input).val();
@@ -1066,6 +1060,19 @@
10661060

10671061
};
10681062

1063+
/**
1064+
* @private
1065+
* Execute function once the timer is reached.
1066+
* If the function is recalled before the timer ends, the first call will be canceled.
1067+
*/
1068+
var _typeWatch = (function(){
1069+
var timer = 0;
1070+
return function(callback, ms){
1071+
clearTimeout (timer);
1072+
timer = setTimeout(callback, ms);
1073+
}
1074+
})();
1075+
10691076
/**
10701077
* @private
10711078
* Executes an anonymous function or a string reached from the window scope.
@@ -1423,9 +1430,7 @@
14231430
}
14241431

14251432
return node.each(function () {
1426-
1427-
window.Validation.form[node.selector] = new Validation(this, options);
1428-
1433+
window.Validation.form[node.selector] = new Validation($(this), options);
14291434
});
14301435

14311436
},

0 commit comments

Comments
 (0)