title: jquery each() only looping through asp.net gridview once
body: <p>I'm trying to loop through a gridview and throw an alert to the user if they haven't filled out the quantity on the item they have checked. But it only works on the first checkbox, and it doesn't return false because the code still executes on the server side. </p>
  
  <pre><code>function GetCheckedRows() {
      var checkBox = $("#flexCheckBoxList")
      var textBox = $("#flexTextBox")
      $("#flexGridView tr").each(function () {
          if ($(checkBox).is(':checked')) {
              if (textBox.val().length === 0) {
                  alert("You must specify the amount needed");
                  return false;
              }
              else {
                  return true;
              }
          }
      });
  }
  </code></pre>
  
  <p>Completed! Wanted to show the finished code that loops through and stops when something isn't correct. I had to create a variable to stop loop execution. This not only checks for an empty value but checks if it is a number too.</p>
  
  <pre><code>function GetCheckedRows() {
      var exitSubmit = false;
      $(".gridView tr").each(function (e) {
          var checkBox = $(this).find("input[type='checkbox']");
          var textBox = $(this).find("input[type='text']");
              if (checkBox.is(':checked')) {
                  if (textBox.val().length === 0 || !$.isNumeric($(textBox).val())) {
                      exitSubmit = true;
                      return false;
              }
              else {
              return true;
              }
          }
      });
      if (exitSubmit) {
         alert("Please enter a valid amount");
         return false;
  }
  </code></pre>
  
  <p>}</p>