Skip to content

Commit 572ddb6

Browse files
author
tom bertrand
committed
Added formData parameter to onSubmit and onError callbacks
1 parent 0e5f7ce commit 572ddb6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

jquery.validation.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@
180180

181181
var errors = [],
182182
messages = {},
183+
formData = {},
183184
delegateSuffix = ".vd", // validation.delegate
184185
resetSuffix = ".vr"; // validation.resetError
185186

@@ -435,13 +436,13 @@
435436
if (!validateForm()) {
436437

437438
displayErrors();
438-
_executeCallback(options.submit.callback.onError, [node, errors]);
439+
_executeCallback(options.submit.callback.onError, [node, errors, formData]);
439440

440441
} else {
441442

442443
_executeCallback(options.submit.callback.onBeforeSubmit, [node]);
443444

444-
(options.submit.callback.onSubmit) ? _executeCallback(options.submit.callback.onSubmit, [node]) : submitForm();
445+
(options.submit.callback.onSubmit) ? _executeCallback(options.submit.callback.onSubmit, [node, formData]) : submitForm();
445446

446447
_executeCallback(options.submit.callback.onAfterSubmit, [node]);
447448

@@ -467,6 +468,8 @@
467468

468469
var isValid = true;
469470

471+
formData = {};
472+
470473
$.each(
471474
node.find('[' + _data.validation + ']:not([disabled]),[' + _data.regex + ']:not([disabled])'),
472475
function (index, input) {
@@ -584,6 +587,8 @@
584587

585588
}
586589

590+
formData[inputName] = value;
591+
587592
return !errors[inputName] || errors[inputName] instanceof Array && errors[inputName].length === 0;
588593

589594
}

0 commit comments

Comments
 (0)