title: check if checkbox is checked before deleting confirm message using javascript
body: <p>I want to make sure that the users checked the checkbox before getting the delete confirmation message using javascript. Can someone please tell me how this can be made possible?</p>
  
  <p>Fiddle:</p>
  
  <p><a href="http://jsfiddle.net/ZmMER/" rel="nofollow">http://jsfiddle.net/ZmMER/</a></p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form name="deleteFiles" action="" method="post" &gt;
      &lt;input type='checkbox' name='files' id='1' onsubmit="return confirm_update();" value='1' /&gt; file 1&lt;br&gt;
  
      &lt;input type="submit" value="Submit" name="submit"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>function confirm_update() {
      var arrCheckboxes = document.deleteFiles.elements["files"];
      if(checkb.checked != true) { 
          alert("You do not have any selected files to delete.");
  
      } else {
          return confirm("Are you sure you want to proceed deleting the selected   files?");
      }
  }
  </code></pre>