Possible Duplicate:
Validating checkboxes present inside gridview with Javascript
This is my aspx code...
<asp:TemplateField HeaderText="IsExist">
<ItemTemplate>
<asp:CheckBox ID="chkExists" runat="server" Text="Exists" AutoPostBack="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Not Exists In Update">
<ItemTemplate>
<asp:CheckBox ID="chkExistsInUpdate" runat="server" Text="NotExists" AutoPostBack="false"/>
</ItemTemplate>
</asp:TemplateField>
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....
function check_one() {
var obj = document.form1;
var isValid = false;
var gridView = document.getElementById('<%= Gridview1.ClientID %>');
for (var i = 1; i < gridView.rows.length; i++) {
var inputs = gridView.rows[i].getElementsByTagName('input');
if (inputs == null) {
if (inputs[0].type == "chkExists" && inputs[0].type == "chkExistsInUpdate") {
if (inputs[0].checked && 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;
}
So plese suggest me that what changes has to do in javascript...