title: Comparing two dates using jQuery
body: <p>I am using Calender plugin to pick two dates respectively from &amp; to. I need to compare value of to always greater than value of from using jQuery as soon as I pick the dates.</p>
  
  <p>I am using the following code </p>
  
  <pre><code>var fromDate = $("#from").val();
  var toDate = $("#to").val();
  if (Date.parse(fromDate) &gt; Date.parse(toDate)) {
      alert("Invalid Date Range!\nStart Date cannot be after End Date!")
      return false;
  } 
  </code></pre>
  
  <p>And the HTML code is:</p>
  
  <pre><code>&lt;input type="text" name="from" id="from" value="" class="datepicker validate[custom[date]]"  tabindex="4" /&gt;
  &lt;input type="text" name="from" id="from" value="" class="datepicker validate[custom[date]]"  tabindex="4" /&gt;
  </code></pre>
  
  <p>If I use jquery validation plugin for comparision:</p>
  
  <pre><code>&lt;input value="" class="validate[required,custom[date],future[2009-01-01]" type="text" id="d1" name="d1" /&gt;
  </code></pre>
  
  <p>As in <a href="http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/" rel="nofollow">http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/</a></p>