libs/web: add field validation for add section name inputs
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 5 Dec 2010 17:37:59 +0000 (17:37 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 5 Dec 2010 17:37:59 +0000 (17:37 +0000)
libs/web/luasrc/view/cbi/tblsection.htm
libs/web/luasrc/view/cbi/tsection.htm

index f5e01de025a4aa0c905519a67478f05264f51b49..860d54ed76840d50da880a5604eeff82ef0d3b8c 100644 (file)
@@ -121,7 +121,8 @@ end
                                        <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:Add%>" />
                                <% else %>
                                        <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
-                                       <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
+                                       <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
+                                       <script type="text/javascript">cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>', true, 'uciname');</script>
                                        <input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />
                                        <% if self.invalid_cts then -%>
                                                <br /><%:Invalid%></div>
index 9361b6d41e40edd6b4a80af0f1bd8d7c561ed830..549934303d054a0c2a9b54185242b63499e6668b 100644 (file)
@@ -50,7 +50,8 @@ $Id$
                                <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" value="<%:Add%>" />
                        <%- else -%>
                                <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
-                               <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
+                               <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
+                               <script type="text/javascript">cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>', true, 'uciname');</script>
                                <input type="submit" class="cbi-button cbi-button-add" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" />
                                <% if self.invalid_cts then -%>
                                        <br /><%:Invalid%></div>