Skip to content

Commit eec73ef

Browse files
committed
prevent other event listeners on submit event when validation fails victorjonsson#372
1 parent bf774f1 commit eec73ef

33 files changed

+59
-49
lines changed

form-validator/brazil.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/date.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/file.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/html5.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/jquery.form-validator.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/** File generated by Grunt -- do not modify
1818
* JQUERY-FORM-VALIDATOR
1919
*
20-
* @version 2.3.22
20+
* @version 2.3.23
2121
* @website http://formvalidator.net/
2222
* @author Victor Jonsson, http://victorjonsson.se
2323
* @license MIT
@@ -998,38 +998,43 @@
998998
.unbind('blur.validation');
999999

10001000
// Validate when submitted
1001-
$form.bind('submit.validation', function () {
1001+
$form.bind('submit.validation', function (evt) {
10021002

1003-
var $form = $(this);
1003+
var $form = $(this),
1004+
stop = function() {
1005+
console.log('stopping');
1006+
evt.stopImmediatePropagation();
1007+
return false;
1008+
};
10041009

10051010
if ($.formUtils.haltValidation) {
10061011
// pressing several times on submit button while validation is halted
1007-
return false;
1012+
return stop();
10081013
}
10091014

10101015
if ($.formUtils.isLoadingModules) {
10111016
setTimeout(function () {
10121017
$form.trigger('submit.validation');
10131018
}, 200);
1014-
return false;
1019+
return stop();
10151020
}
10161021

10171022
var valid = $form.isValid(conf.language, conf);
10181023

10191024
if ($.formUtils.haltValidation) {
10201025
// Validation got halted by one of the validators
1021-
return false;
1026+
return stop();
10221027
} else {
10231028
if (valid && typeof conf.onSuccess === 'function') {
10241029
var callbackResponse = conf.onSuccess($form);
10251030
if (callbackResponse === false) {
1026-
return false;
1031+
return stop();
10271032
}
10281033
} else if (!valid && typeof conf.onError === 'function') {
10291034
conf.onError($form);
1030-
return false;
1035+
return stop();
10311036
} else {
1032-
return valid;
1037+
return valid ? true : stop();
10331038
}
10341039
}
10351040
})

form-validator/jquery.form-validator.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/jsconf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** File generated by Grunt -- do not modify
22
* JQUERY-FORM-VALIDATOR
33
*
4-
* @version 2.3.22
4+
* @version 2.3.23
55
* @website http://formvalidator.net/
66
* @author Victor Jonsson, http://victorjonsson.se
77
* @license MIT

form-validator/lang/ca.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/cz.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/de.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/dk.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/es.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/fr.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/it.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/nl.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/no.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/pl.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/pt.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/ro.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/ru.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/sv.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/location.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/logic.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/poland.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/sanitize.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/security.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/sepa.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/sweden.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/toggleDisabled.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/uk.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

formvalidator.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"validation",
88
"validator"
99
],
10-
"version": "2.3.22",
10+
"version": "2.3.23",
1111
"author": {
1212
"name": "Victor Jonsson",
1313
"url": "http://victorjonsson.se",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-form-validator",
33
"description": "With this feature rich jQuery plugin it becomes easy to validate user input while keeping your HTML markup clean from javascript code. Even though this plugin has a wide range of validation functions it's designed to require as little bandwidth as possible. This is achieved by grouping together validation functions in \"modules\", making it possible for the programmer to load only those functions that's needed to validate a particular form.",
4-
"version": "2.3.22",
4+
"version": "2.3.23",
55
"main": "./form-validator/jquery.form-validator.min.js",
66
"keywords": [
77
"form",

src/main/setup.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,38 +95,43 @@
9595
.unbind('blur.validation');
9696

9797
// Validate when submitted
98-
$form.bind('submit.validation', function () {
98+
$form.bind('submit.validation', function (evt) {
9999

100-
var $form = $(this);
100+
var $form = $(this),
101+
stop = function() {
102+
console.log('stopping');
103+
evt.stopImmediatePropagation();
104+
return false;
105+
};
101106

102107
if ($.formUtils.haltValidation) {
103108
// pressing several times on submit button while validation is halted
104-
return false;
109+
return stop();
105110
}
106111

107112
if ($.formUtils.isLoadingModules) {
108113
setTimeout(function () {
109114
$form.trigger('submit.validation');
110115
}, 200);
111-
return false;
116+
return stop();
112117
}
113118

114119
var valid = $form.isValid(conf.language, conf);
115120

116121
if ($.formUtils.haltValidation) {
117122
// Validation got halted by one of the validators
118-
return false;
123+
return stop();
119124
} else {
120125
if (valid && typeof conf.onSuccess === 'function') {
121126
var callbackResponse = conf.onSuccess($form);
122127
if (callbackResponse === false) {
123-
return false;
128+
return stop();
124129
}
125130
} else if (!valid && typeof conf.onError === 'function') {
126131
conf.onError($form);
127-
return false;
132+
return stop();
128133
} else {
129-
return valid;
134+
return valid ? true : stop();
130135
}
131136
}
132137
})

0 commit comments

Comments
 (0)