title: Allow only one checkbox selected when certain button clicked
body: <p>I have the following code:</p>
  
  <pre><code>$("input.edit_user").click(function() {
      var theCheckboxes = $("input[type='checkbox']"); 
      if (theCheckboxes.filter(":checked").length &gt; 1)
          $(this).removeAttr("checked");
          alert( "Please selected one user at a time for editing." );
  });
  .
  .
  .
  &lt;tr&gt;
      &lt;td&gt;&lt;input type="checkbox" name="user_id[]" value="1"&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="checkbox" name="user_id[]" value="2"&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="checkbox" name="user_id[]" value="3"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  .
  .
  .
  &lt;input type="submit" name="submit" value="Edit Selected User" class="edit_user"&gt;
  </code></pre>
  
  <p>I'm using checkboxes, because there are other options that allow for more than one item to be selected.</p>
  
  <p>However, When a user selects a checkbox for editing, I need to alert them they are only allowed to select one checkbox at a time.</p>
  
  <p>I think I have the right idea with my code, but I'm going about it the wrong way, since it's not working and just continues to process the page normally.</p>
  
  <p>Suggestions?</p>
  
  <hr>
  
  <p><strong>UPDATE on selected solution and why</strong></p>
  
  <p>For the viable solutions below, once I added:</p>
  
  <pre><code>$(document).ready(function() { 
  </code></pre>
  
  <p>in my working example, they started working. I selected the answer I did, because after the above line was added, all I needed was the </p>
  
  <pre><code>return false;
  </code></pre>
  
  <p>line (and correct brackets on the inner if statement) in order to stop the page from executing what remains.</p>
  
  <p>Thank you all for your help solving this!</p>