title: Comparing two dates in array in Javascript
body: <p>I have a form where I am fetching two Dates from input tag. I need to validate and compare a date should always be greater than the another date. Here is javascript below :</p>
  
  <pre><code>function validateDD(gateout_plnd_dt){
      var dt_pat = /^[0-9]{2}-[0-9]{2}-[0-9]{4}$/;
      var alpha = /^[a-zA-Z0-9\s\.\-]+$/
      var int = /^[0-9.]+$/;
      var gateout_plnd_dt = document.getElementsByName('gateout_plnd_dt[]');
      var gate_in_dt = document.getElementsByName('gate_in_dt[]');
  
  
      for(var i=0,j=0; i&lt;gateout_plnd_dt.length,j&lt;gate_in_dt.length; i++,j++){
  
  
  
          if(gateout_plnd_dt[i].value&lt; gate_in_dt[j].value){
          alert((gateout_plnd_dt[i].value));
          alert(gate_in_dt[j].value);
           return false;
          }
          }
  
  
      }
  </code></pre>
  
  <p>I need to convert it from string into date object which i am unable to do so. Will be really helpful to get it done. Thanks. </p>