title: Javascript: how to validate dates in format MM-DD-YYYY?
body: <p>I saw a potential answer here but that was for YYYY-MM-DD: <a href="http://paulschreiber.com/blog/2007/03/02/javascript-date-validation/" rel="noreferrer">JavaScript date validation</a></p>
  
  <p>I modified the code code above for MM-DD-YYYY like so but I still can't get it to work:</p>
  
  <pre><code>String.prototype.isValidDate = function() 
  {
       var IsoDateRe = new RegExp("^([0-9]{2})-([0-9]{2})-([0-9]{4})$");
       var matches = IsoDateRe.exec(this);
       if (!matches) return false;
       var composedDate = new Date(matches[3], (matches[1] - 1), matches[2]);
       return ((composedDate.getMonth() == (matches[1] - 1)) &amp;&amp;
        (composedDate.getDate() == matches[2]) &amp;&amp;
        (composedDate.getFullYear() == matches[3]));
  }
  </code></pre>
  
  <p>How can I get the above code to work for MM-DD-YYYY and better yet MM/DD/YYYY?</p>
  
  <p>Thanks.</p>