From 58447640eb4704ce5bed612f84cb86b84afa17fa Mon Sep 17 00:00:00 2001 From: Helge Mader Date: Fri, 12 Mar 2021 10:48:29 +0100 Subject: [PATCH] luci-base: prevent empty field for adding new entry Signed-off-by: Florian Eckert --- modules/luci-base/htdocs/luci-static/resources/cbi.js | 11 +++++++++++ modules/luci-compat/luasrc/view/cbi/tblsection.htm | 4 ++-- modules/luci-compat/luasrc/view/cbi/tsection.htm | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index b66fe684a5..d6020e9d58 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -367,6 +367,17 @@ function cbi_validate_form(form, errmsg) return true; } +function cbi_validate_named_section_add(input) +{ + var button = input.parentNode.parentNode.querySelector('.cbi-button-add'); + if (input.value !== '') { + button.disabled = false; + } + else { + button.disabled = true; + } +} + function cbi_validate_reset(form) { window.setTimeout( diff --git a/modules/luci-compat/luasrc/view/cbi/tblsection.htm b/modules/luci-compat/luasrc/view/cbi/tblsection.htm index 048eb22c41..1cba660884 100644 --- a/modules/luci-compat/luasrc/view/cbi/tblsection.htm +++ b/modules/luci-compat/luasrc/view/cbi/tblsection.htm @@ -192,9 +192,9 @@ end
<%:Invalid%>
<%- end %>
- +
- + <% end %> <%- end %> diff --git a/modules/luci-compat/luasrc/view/cbi/tsection.htm b/modules/luci-compat/luasrc/view/cbi/tsection.htm index 45e51cc69f..703e1ff328 100644 --- a/modules/luci-compat/luasrc/view/cbi/tsection.htm +++ b/modules/luci-compat/luasrc/view/cbi/tsection.htm @@ -42,9 +42,9 @@
<%:Invalid%>
<%- end %>
- +
- + <%- end %> <%- end %> -- 2.30.2