title: loop through all the text-boxes of a table and check the mandatory values
body: <p>I have a table of 3 columns and 10 rows which contains text fields. If I add any values into any of the cell, the corresponding row's first column field is mandatory and if there is no text it will throw an error message like "please add value in column 1" and the program will be paused to correct the input. How can I achieve this using jQuery?</p>
  
  <p>My sample code:</p>
  
  <pre><code>$(function() {$("#mySubmit").click(function(event) {
  
  $('#myTable tr').each(function(event) {
      if ($(this).find("td:first").length &gt; 0) {
          var firstColumn     = $(this).find("td input").eq(0).val(); 
          var secondColumn = $(this).find("td input").eq(1).val();
          if (typeof (secondColumn) != "undefined") {
                  var lengthOfSecondColumn = secondColumn.length;
                  var lengthOfFirstColumn = firstColumn.length;
  
                  alert(lengthOfFirstColumn + ' ' + lengthOfSecondColumn )
  
                  if (lengthOfSecondColumn &gt; 0) {
  
                      if(lengthOfFirstColumn &lt; 1){
                          alert('Please add value in first column');
                          event.preventDefault();
                      }               
                  }
          }                                       
      }
  });
  
      $.ajax({
      type : "POST",
      url : "updateURL",
      data : dataString,
      success : function(data) {
          if (data.checkingStatus == 0) {
              alert("updated");
          }
  
          else (data.checkingStatus == -1) {
              alert("...");
          }
      }
      });
  
  });
  </code></pre>
  
  <p>I tried to do this. But it is executed and redirects to custom error handling page.</p>