0
<tr>
                        <td height="12" align="left" class="cont">
                            <asp:CheckBox ID="chkacsoutreach" runat="server" />Acs Outreach                        </td>
                    </tr>
                    <tr>
                        <td height="12" align="left" class="cont">
                           <asp:CheckBox ID="chkaceportal" runat="server" /> Ace Portal                        </td>
                    </tr>

I took some checkboxes in the following way.I should get a message if atleast 1 checkbox is not checked and the values should not be entered into the database.This is the validation i needed.I have written the javascript code as below:but instead of 'controls[]' there should be a groupname which combines all the checkboxes.Iam not understanding what name to give here.Can any one please help me out

<script type="text/javascript" language="javascript">
                      function validate() {                          var chks = document.getElementsByName('controls[]');                          var hasChecked = false;                          for (var i = 0; i < chks.length; i++) {                              if (chks[i].checked) {                                  hasChecked = true;                                  break;                              }                          }                          if (hasChecked == false) {                              alert("Please select at least one.");                              return false;                          }                          return true;                      }                          </script>

Edited by __avd: Added [code] tags. Do wrap your programming code blocks within [code] ... [/code] tags

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by __avd
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.