jQuery iteration logic issue.. Logic in a function
<p>JQuery noob here.  I need some help it's prob basic, but I would really appreciate if someone would help me. I am working on an old grotesque page that needs to compare dates for departure/arrival to see if they are invalid. This is the logic I came up with to compare the dates which works perfectly (for one date). </p>

<p>The issue I have though is there are 9 dates that need to be compared, #AD1 and #DD1 through #AD9 and #DD9, with each line in a separate table row with a class named ".dateVal". How would I encapsulate this code to run through these 9 dates in a function? I really appreciate the help in advance.. Thanks MUCH!</p>

<pre><code>  var strErrors = '';
  var strRequired = '';

  var iniString = '';
  var endString = '';
  var dateIni = $('#AD1').val().split('/');
  var dateEnd = $('#DD1').val().split('/');
  $.each(dateIni, function (index, value) {
   iniString = iniString + value;
  })
  $.each(dateEnd, function (index, value) {
   endString = endString + value;
  })

  iniString = parseInt(iniString, 10);
  endString = parseInt(endString, 10);


  if (iniString &gt; endString) {
   strErrors = strErrors + ' - Departure/Arrival dates are incorrect.  \n'
  }
</code></pre>
