diff options
author | Lukas Voegl <lvoegl@tdt.de> | 2021-10-13 12:20:48 +0200 |
---|---|---|
committer | Lukas <lvoegl@tdt.de> | 2021-10-26 12:31:05 +0200 |
commit | 735d949bfc3168751567f3c991c8d5c845559f23 (patch) | |
tree | 229c39988ca3b8a46f6ffd3c110e4bfca1aa23c8 /modules/luci-base/htdocs/luci-static/resources/ui.js | |
parent | 37e40e04ef04307660c35eb089deb6cbde17d660 (diff) |
luci-base: show validation message in error
Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources/ui.js')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/ui.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index 9cc62c12db..9f3e74b935 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -156,6 +156,18 @@ var UIElement = baseclass.extend(/** @lends LuCI.ui.AbstractElement.prototype */ }, /** + * Returns the current validation error + * + * @instance + * @memberof LuCI.ui.AbstractElement + * @returns {string} + * The validation error at this time + */ + getValidationError: function() { + return this.validationError || ''; + }, + + /** * Force validation of the current input value. * * Usually input validation is automatically triggered by various DOM events @@ -243,10 +255,12 @@ var UIElement = baseclass.extend(/** @lends LuCI.ui.AbstractElement.prototype */ this.node.addEventListener('validation-success', L.bind(function(ev) { this.validState = true; + this.validationError = ''; }, this)); this.node.addEventListener('validation-failure', L.bind(function(ev) { this.validState = false; + this.validationError = ev.detail.message; }, this)); }, |