title: javascript regexp, validating date problem
body: <p>I have some code for validating date below:</p>
  
  <pre><code>
  function validateForm() {
  var errFound = 0;       
  //var patt_date = new RegExp("^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))$");
  var patt_date = new RegExp("^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$");
  if (patt_date.test(document.getElementById("datefrom").value) == false){errFound = errFound + 1;document.getElementById("datefrom").className = "error";}
  
  if (errFound > 0)
      alert('Please correct red colored field!');
  else
      return true;
  return false;   
  }
  </code></pre>
  
  <p><br>
  Above code should work with YYYY-MM-DD format, but fail to validate date such as <b>"2009-02-29"</b></p>
  
  <p>The commented code should work <b>(//var patt_date = new RegExp...)</b>, it can catch <b>"2009-02-29"</b>,<br> but it ruin the validation when i put invalid data and try to correct it, it keeps complain there something wrong with form value after i had correct them (especially on form with multiple input)</p>
  
  <p>Maybe someone can fix the current regex?
  <hr>
  <b>Edited</b>, what i want just a simple replacement for above regexp, mean a new regexp pattern not the whole new method to validate date<br>
  And for reference, i simply grab the regexp pattern from:<br>
  <a href="http://www.regexlib.com/REDetails.aspx?regexp_id=694" rel="nofollow noreferrer">http://www.regexlib.com/REDetails.aspx?regexp_id=694</a> and<br>
  <a href="http://www.regexlib.com/REDetails.aspx?regexp_id=933" rel="nofollow noreferrer">http://www.regexlib.com/REDetails.aspx?regexp_id=933</a></p>
  
  <p>Tested with <b>2009-02-29</b>, 1st link work &amp; 2nd not. Again the problem was only the 2nd regexp didn't detect value <b>2009-02-29</b> as invalid while 1st can (but it ruin my code? so it's must be there something wrong with it).</p>
  
  <p>Thanks,<br>
  Dels</p>