Validating checkboxes present inside gridview with Javascript
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7499276/validating-checkboxes-present-inside-gridview-with-javascript">Validating checkboxes present inside gridview with Javascript</a>  </p>
</blockquote>



<pre><code>This is my aspx code...
 &lt;asp:TemplateField HeaderText="IsExist"&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:CheckBox ID="chkExists" runat="server" Text="Exists" AutoPostBack="false" /&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
        &lt;asp:TemplateField HeaderText="Not Exists In Update"&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:CheckBox ID="chkExistsInUpdate" runat="server" Text="NotExists" AutoPostBack="false"/&gt;

            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
</code></pre>

<p>Here I have 2 checkboxes but in different columns i.e. chkExist for Exist column and chkExistInUpdate for NotExist column in gridview. I want If they both checked then alert() mesg should display like "You can check Only one checkbox"..
So here is my javascript code....</p>

<pre><code> function check_one() {
            var obj = document.form1;
            var isValid = false;
            var gridView = document.getElementById('&lt;%= Gridview1.ClientID %&gt;');
            for (var i = 1; i &lt; gridView.rows.length; i++) {
                var inputs = gridView.rows[i].getElementsByTagName('input');
                if (inputs == null) {
                    if (inputs[0].type == "chkExists" &amp;&amp; inputs[0].type == "chkExistsInUpdate") {
                        if (inputs[0].checked &amp;&amp; inputs[0].checked) {
                            isValid = true;

                        }

                    }
                    var ch1 = inputs[0].type["chkExists"];


                }
                //alert(inputs[0].type == "chkExists");
                alert(ch1);

            }
            alert("Plese select only 1 check");
            return false;

        }
</code></pre>

<p>So plese suggest me that what changes has to do in javascript...</p>
