Browse Source

feature: checker

es6
guy 3 years ago
parent
commit
307bc13b00
  1. 23
      src/base/single/input/input.js

23
src/base/single/input/input.js

@ -207,13 +207,24 @@ BI.Input = BI.inherit(BI.Single, {
}, },
_checkValidationOnValueChange: function () { _checkValidationOnValueChange: function () {
var o = this.options; var self = this, o = this.options;
var v = this.getValue(); var v = this.getValue();
this.setValid( if (o.allowBlank === true && BI.trim(v) == "") {
(o.allowBlank === true && BI.trim(v) == "") || ( this.setValid(true);
BI.isNotEmptyString(BI.trim(v)) && o.validationChecker.apply(this, [BI.trim(v)]) !== false return;
) }
); if (BI.trim(v) == "") {
this.setValid(false);
return;
}
var checker = o.validationChecker.apply(this, [BI.trim(v)]);
if (checker instanceof Promise) {
checker.then(function (validate) {
self.setValid(validate !== false);
})
} else {
this.setValid(checker !== false);
}
}, },
focus: function () { focus: function () {

Loading…
Cancel
Save