|
@@ -29,6 +29,7 @@
|
|
|
var el = document.createElement('div');
|
|
var el = document.createElement('div');
|
|
|
this._changeEvent = ('oninput' in el) ? 'input' : 'keydown';
|
|
this._changeEvent = ('oninput' in el) ? 'input' : 'keydown';
|
|
|
|
|
|
|
|
|
|
+ this._submitIfValid = null;
|
|
|
this._init();
|
|
this._init();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -127,6 +128,8 @@
|
|
|
})
|
|
})
|
|
|
.on('click', this.options.submitButtons, function() {
|
|
.on('click', this.options.submitButtons, function() {
|
|
|
that.$submitButton = $(this);
|
|
that.$submitButton = $(this);
|
|
|
|
|
+ // The user just click the submit button
|
|
|
|
|
+ that._submitIfValid = true;
|
|
|
})
|
|
})
|
|
|
// Find all fields which have either "name" or "data-bv-field" attribute
|
|
// Find all fields which have either "name" or "data-bv-field" attribute
|
|
|
.find('[name], [data-bv-field]').each(function() {
|
|
.find('[name], [data-bv-field]').each(function() {
|
|
@@ -226,6 +229,7 @@
|
|
|
|
|
|
|
|
// Whenever the user change the field value, mark it as not validated yet
|
|
// Whenever the user change the field value, mark it as not validated yet
|
|
|
$field.on(event + '.update.bv', function() {
|
|
$field.on(event + '.update.bv', function() {
|
|
|
|
|
+ that._submitIfValid = false; // Reset the flag
|
|
|
updateAll ? that.updateStatus(field, that.STATUS_NOT_VALIDATED, null)
|
|
updateAll ? that.updateStatus(field, that.STATUS_NOT_VALIDATED, null)
|
|
|
: that.updateElementStatus($(this), that.STATUS_NOT_VALIDATED, null);
|
|
: that.updateElementStatus($(this), that.STATUS_NOT_VALIDATED, null);
|
|
|
});
|
|
});
|
|
@@ -475,9 +479,11 @@
|
|
|
updateAll ? that.updateStatus($f.attr('data-bv-field'), isValid ? that.STATUS_VALID : that.STATUS_INVALID, v)
|
|
updateAll ? that.updateStatus($f.attr('data-bv-field'), isValid ? that.STATUS_VALID : that.STATUS_INVALID, v)
|
|
|
: that.updateElementStatus($f, isValid ? that.STATUS_VALID : that.STATUS_INVALID, v);
|
|
: that.updateElementStatus($f, isValid ? that.STATUS_VALID : that.STATUS_INVALID, v);
|
|
|
|
|
|
|
|
- if (isValid && 'disabled' == that.options.live && that.$submitButton) {
|
|
|
|
|
- that._submit();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (isValid && that._submitIfValid == true) {
|
|
|
|
|
+ // If a remote validator returns true
|
|
|
|
|
+ // and the form is ready to submit, then do it
|
|
|
|
|
+ that._submit();
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
} else if ('boolean' == typeof validateResult) {
|
|
} else if ('boolean' == typeof validateResult) {
|
|
|
updateAll ? this.updateStatus(field, validateResult ? this.STATUS_VALID : this.STATUS_INVALID, validatorName)
|
|
updateAll ? this.updateStatus(field, validateResult ? this.STATUS_VALID : this.STATUS_INVALID, validatorName)
|