Skip to content

Commit bd97087

Browse files
committed
Important bug fix in async validators, making it possible to fool the validator
1 parent b9d0718 commit bd97087

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/main/async.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
var disableFormSubmit = function () {
66
return false;
77
},
8+
lastFormEvent = null,
89
HaltManager = {
910
numHalted: 0,
1011
haltValidation: function($form) {
@@ -48,7 +49,8 @@
4849
if (eventContext === 'keyup') {
4950
return null;
5051
} else if (this.isRunning) {
51-
if (!this.haltedFormValidation && eventContext === 'submit') {
52+
lastFormEvent = eventContext;
53+
if (!this.haltedFormValidation) {
5254
HaltManager.haltValidation();
5355
this.haltedFormValidation = true;
5456
}
@@ -57,10 +59,9 @@
5759
//this.$input.one('keyup change paste', this.reset.bind(this));
5860
return this.result;
5961
} else {
60-
if (eventContext === 'submit') {
61-
HaltManager.haltValidation(this.$form);
62-
this.haltedFormValidation = true;
63-
}
62+
lastFormEvent = eventContext;
63+
HaltManager.haltValidation(this.$form);
64+
this.haltedFormValidation = true;
6465
this.isRunning = true;
6566
this.$input
6667
.attr('disabled', 'disabled')
@@ -85,9 +86,11 @@
8586
this.$form.removeClass('async-validation');
8687
if (this.haltedFormValidation) {
8788
HaltManager.unHaltValidation(this.$form);
88-
this.$form.trigger('submit');
89-
} else {
90-
this.$input.trigger('validation.revalidate');
89+
if (lastFormEvent == 'submit') {
90+
this.$form.trigger('submit');
91+
} else {
92+
this.$input.trigger('validation.revalidate');
93+
}
9194
}
9295
};
9396

src/modules/security.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,6 @@
397397
$input.removeClass('validating-server-side');
398398
if (response.message) {
399399
$input.attr(conf.validationErrorMsgAttribute, response.message);
400-
$input.one('validation', function() {
401-
$input.removeAttr(conf.validationErrorMsgAttribute);
402-
});
403400
}
404401
done(response.valid);
405402
});

0 commit comments

Comments
 (0)