diff options
author | Florian Eckert <fe@dev.tdt.de> | 2021-08-11 09:35:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-11 09:35:24 +0200 |
commit | d81564e064c4b2d51db0900e50ac91a39382e55c (patch) | |
tree | 4e9b204ca33b98b73bdb785b61ef3216bb8ccc4d /modules | |
parent | b5af813318316e26592971c73a10a455493de7d5 (diff) | |
parent | 58447640eb4704ce5bed612f84cb86b84afa17fa (diff) |
Merge pull request #5154 from TDT-AG/pr/20210628-luci-compat
luci-base: prevent empty field for adding new entry
Diffstat (limited to 'modules')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/cbi.js | 11 | ||||
-rw-r--r-- | modules/luci-compat/luasrc/view/cbi/tblsection.htm | 4 | ||||
-rw-r--r-- | 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 513256e4c9..9728e03e12 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 <div class="cbi-section-error"><%:Invalid%></div> <%- end %> <div> - <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" /> + <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" onkeyup="cbi_validate_named_section_add(this)"/> </div> - <input class="btn cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" /> + <input class="btn cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" disabled="" /> <% end %> </div> <%- 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 @@ <div class="cbi-section-error"><%:Invalid%></div> <%- end %> <div> - <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>." name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>." data-type="uciname" data-optional="true" /> + <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>." name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>." data-type="uciname" data-optional="true" onkeyup="cbi_validate_named_section_add(this)"/> </div> - <input class="btn cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" /> + <input class="btn cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" disabled=""/> <%- end %> </div> <%- end %> |