summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorHelge Mader <ma@dev.tdt.de>2021-03-12 15:47:38 +0100
committerFlorian Eckert <fe@dev.tdt.de>2021-07-01 13:10:15 +0200
commit87215e3d1bd2406c4a5ae5088e176fb4aefbe546 (patch)
tree10237ac9e5e4c6bdb75156b31a58d8dafbacaabb /modules
parent80262bb9a7e63eeee0e1fa5f290b27a569a644bf (diff)
luci-base: prevent empty field for adding new named section in JavaScript
Suggested-by: Helge Mader <ma@dev.tdt.de> Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/form.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js
index 29e8fa7f05..e9c8d2eb00 100644
--- a/modules/luci-base/htdocs/luci-static/resources/form.js
+++ b/modules/luci-base/htdocs/luci-static/resources/form.js
@@ -2212,11 +2212,21 @@ var CBITypedSection = CBIAbstractSection.extend(/** @lends LuCI.form.TypedSectio
return this.handleAdd(ev, nameEl.value);
}),
- 'disabled': this.map.readonly || null
+ 'disabled': true
}, [ btn_title || _('Add') ])
]);
- ui.addValidator(nameEl, 'uciname', true, 'blur', 'keyup');
+ ui.addValidator(nameEl, 'uciname', true, function(v) {
+ var button = document.querySelector('.cbi-section-create > .cbi-button-add');
+ if (v !== '') {
+ button.disabled = false;
+ return true;
+ }
+ else {
+ button.disabled = true;
+ return _('Expecting: %s').format(_('non-empty value'));
+ }
+ }, 'blur', 'keyup');
}
return createEl;