mithun kumar

mithun kumar

  • NA
  • 20
  • 17.9k

using javascript code to validate the checkbox in Grid view

May 29 2012 3:15 AM
Hi Friends,

<script type="text/javascript" language="javascript" >
function validateCheckBoxes() {
var isValid = false;
var gridView = document.getElementById('<%= GrdEmp.ClientID %>');
for (var i = 1; i < gridView.rows.length; i++) {
var inputs = gridView.rows[i].getElementsByTagName('input');
if (inputs != null) {
if (inputs[0].type == "checkbox") {
if (inputs[0].checked) {
isValid = true;
return true;
}
}
}
}
alert("Please select atleast one checkbox");
return false;
}
</script>

This code was working fine ...but today its giving me error:
Microsoft JScript runtime error: '0.type' is null or not an object

Thanks & Regards,
Mithun.

Answers (2)