title: How to show alert message using javascript to check checkbox?
body: <p>I am using following code to detect whether the check box inside my gridview template field is checked or not. If none of the check box is selected then I want to show alert message. </p>
  
  <pre><code>   function findCheckBox() {
  
          var inputElements = document.getElementsByTagName('input');
          var chekSelect = false;
          for (var i = 0; i &lt; inputElements.length; i++) {
              var myElement = inputElements[i];
  
  
              if (myElement.type === "checkbox") {
  
                  if (myElement.checked === false) {
  
                      chekSelect = true;
                      return true;
                  }
              }
  
              if (chekSelect === true) {
                  return true;
              }
  
              else {
                  alert('Please Check Atleast one record to print cheque!!!');
                  return false;
              }
          }  
  
      }
  </code></pre>
  
  <p>But with this code when I click on my button its showing me error message for one time even if one or more check box is checked. What I am doing wrong here. Can anyone help me please.</p>