Q:

How check at lease one checkbox is checked inside ASP.NET repeater control in Javascript

In my asp.net website; i have REPEATER control having child control checklistbox , dynamically generates in code behind.
I would like to know how can i write javascript function where i have to check at least one checkbox should be checked.
Ho can i acheive? Please Help?

A:

You could wrap the list of checkboxes in a container (e.g. a <div>) with a known ID:
<div id="myCheckboxes">
  <input type="checkbox" ...>
  <!-- ... -->
  <input type="checkbox" ...>
</div>

And then in JavaScript do:
function isOneChecked(containerId) {
  var myDiv = document.getElementByID(containerId);
  if (myDiv != null) {
    var checkBoxes = myDiv.getElementsByTagName("INPUT");

    for (var i=0; i<checkBoxes.length; i++) {
      if (checkBoxes[i].checked == true) {
        return true;
      }
    }
  }
  return false;
}

and call it as:
if (isOneChecked("myCheckboxes")) {
  // whatever
}

