Need help with a JavaScript function to determine ascending numbers
<p>I have table rows, which have a <em>start</em> number and an <em>end</em> number (input fields).</p>

<p>Per row, the end <strong>must</strong> be larger than the start.</p>

<p>From inputs left to right, top to bottom the numbers must be larger than the last.</p>

<p>So there are 2 inputs per row, and 4 (for example) rows. Each number is bigger than the last.</p>

<p>I've been trying to validate this using this function</p>

<pre><code>   var maxDepth = 0,
  didValidate = true;

// I assume this reads from left to right top to bottom as they are that way in the markup
$('.input-start-depth, .input-end-depth').each(function(i) {

  maxDepth = Math.max(maxDepth, parseFloat($(this).val(), 10));

  var isStart = ($(this).hasClass('input-start-depth'));
  var value = $(this).val();


  if (isStart &amp;&amp; value &gt; maxDepth) {
    didValidate = false;

    return false;
  };

  lastValue = value;

});
</code></pre>

<p>I've been racking my head to get this to work. The other important thing is the number of rows is dynamic, there could be 1 or 10,000 or any in between.</p>

<p>Basically it is meant to say if the start depth is larger than the max depth so far, it should fail. </p>

<p>But it is validating numbers when they shouldn't be valid.</p>

<p>What am I doing wrong?</p>

<p>Cheers.</p>
