Browse Source

feature: checker

es6
guy 2 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 () {
var o = this.options;
var self = this, o = this.options;
var v = this.getValue();
this.setValid(
(o.allowBlank === true && BI.trim(v) == "") || (
BI.isNotEmptyString(BI.trim(v)) && o.validationChecker.apply(this, [BI.trim(v)]) !== false
)
);
if (o.allowBlank === true && BI.trim(v) == "") {
this.setValid(true);
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 () {

Loading…
Cancel
Save