From fff0cc07dfd95110888086ff41d55e210b9b30f1 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 9 May 2022 23:54:35 +0800 Subject: [PATCH] update --- src/base/single/input/input.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index 145129dc2..e868a5747 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -206,24 +206,28 @@ BI.Input = BI.inherit(BI.Single, { this._lastValue = this.getValue(); }, - _checkValidationOnValueChange: function () { + _checkValidationOnValueChange: function (callback) { var self = this, o = this.options; var v = this.getValue(); if (o.allowBlank === true && BI.trim(v) == "") { this.setValid(true); + callback && callback(); return; } if (BI.trim(v) == "") { this.setValid(false); + callback && callback(); return; } var checker = o.validationChecker.apply(this, [BI.trim(v)]); if (checker instanceof Promise) { checker.then(function (validate) { self.setValid(validate !== false); + callback && callback(); }) } else { this.setValid(checker !== false); + callback && callback(); } }, @@ -256,14 +260,16 @@ BI.Input = BI.inherit(BI.Single, { }, setValue: function (textValue) { + var self = this; this.element.val(textValue); - BI.nextTick(BI.bind(function () { - this._checkValidationOnValueChange(); - this._defaultState(); - if (this.isValid()) { - this._lastValidValue = this._lastSubmitValue = this.getValue(); - } - }, this)); + BI.nextTick(function () { + self._checkValidationOnValueChange(function () { + self._defaultState(); + if (self.isValid()) { + self._lastValidValue = self._lastSubmitValue = self.getValue(); + } + }); + }); }, getValue: function () {