title: Validation of Invalid Date/ Leap Year
body: <p>Trying to use jquery to do this, I found a plugin called "real date validation". I cant seem to implement it correctly.</p>
  
  <p>Can anyone help me? Trying to validate that the date 2-31-[whateveryear] shouldnt work, along with leap years...</p>
  
  <pre><code>&lt;?php 
  $month = $_POST["mo"];
  $day = $_POST["theDay"];
  $yr = $_POST["year"];
  if (!isset($_POST['submit'])) { // if page is not submitted; echo form
  ?&gt;
  &lt;script type="text/javascript" src="jquery.js"&gt; &lt;/script&gt;
  &lt;script type="text"&gt;
   $(document).ready(function() {
    var month = $('#mo').val();
    var day = $('#tDay').val();
    var year = $('#tYear').val();
    var date = new Date(month+"/"+day+"/"+year);
  
    if(day == "29" &amp;&amp; month == "02") {
    if(year % 4 == 0 &amp;&amp; ( year % 100 != 0 || year % 400 == 0)) {
    return true
    } else { return false; }
    } else if(month == (date.getMonth()+1) &amp;&amp; day == date.getDate() &amp;&amp; year == date.getFullYear()) {
    return true;
    } else { return false; }
  });
  &lt;/script&gt;
  
  
  
  
  &lt;h2 style="margin:0; padding:0;"&gt;Date Selection&lt;/h2&gt;
  &lt;FORM method="POST" action="&lt;?php echo $PHP_SELF;?&gt;"&gt; 
   &lt;select name="mo" id="mo"&gt;
     &lt;option disabled="disabled"&gt;SELECT MONTH&lt;/option&gt;
     &lt;option&gt;January&lt;/option&gt;
     &lt;option&gt;February&lt;/option&gt;
     &lt;option&gt;March&lt;/option&gt;
     &lt;option&gt;April&lt;/option&gt;
     &lt;option&gt;May&lt;/option&gt;
     &lt;option&gt;June&lt;/option&gt;
     &lt;option&gt;July&lt;/option&gt;
     &lt;option&gt;August&lt;/option&gt;
     &lt;option&gt;September&lt;/option&gt;
     &lt;option&gt;October&lt;/option&gt;
     &lt;option&gt;November&lt;/option&gt;
     &lt;option&gt;December&lt;/option&gt;
   &lt;/select&gt;
   &lt;select name="theDay" id="tDay"&gt;
     &lt;option disabled="disabled"&gt;SELECT DAY&lt;/option&gt;
     &lt;option&gt;1&lt;/option&gt;
     &lt;option&gt;2&lt;/option&gt;
     &lt;option&gt;3&lt;/option&gt;
     &lt;option&gt;4&lt;/option&gt;
     &lt;option&gt;5&lt;/option&gt;
     &lt;option&gt;6&lt;/option&gt;
     &lt;option&gt;7&lt;/option&gt;
     &lt;option&gt;8&lt;/option&gt;
     &lt;option&gt;9&lt;/option&gt;
     &lt;option&gt;10&lt;/option&gt;
     &lt;option&gt;11&lt;/option&gt;
     &lt;option&gt;12&lt;/option&gt;
     &lt;option&gt;13&lt;/option&gt;
     &lt;option&gt;14&lt;/option&gt;
     &lt;option&gt;15&lt;/option&gt;
     &lt;option&gt;16&lt;/option&gt;
     &lt;option&gt;17&lt;/option&gt;
     &lt;option&gt;18&lt;/option&gt;
     &lt;option&gt;19&lt;/option&gt;
     &lt;option&gt;20&lt;/option&gt;
     &lt;option&gt;21&lt;/option&gt;
     &lt;option&gt;22&lt;/option&gt;
     &lt;option&gt;23&lt;/option&gt;
     &lt;option&gt;24&lt;/option&gt;
     &lt;option&gt;25&lt;/option&gt;
     &lt;option&gt;26&lt;/option&gt;
     &lt;option&gt;27&lt;/option&gt;
     &lt;option&gt;28&lt;/option&gt;
     &lt;option&gt;29&lt;/option&gt;
     &lt;option&gt;30&lt;/option&gt;
     &lt;option&gt;31&lt;/option&gt;
   &lt;/select&gt;
  
   &lt;select name="year" id="tYear"&gt;
     &lt;option disabled="disabled"&gt;SELECT YEAR&lt;/option&gt;
     &lt;option&gt;2011&lt;/option&gt;
     &lt;option&gt;2010&lt;/option&gt;
     &lt;option&gt;2009&lt;/option&gt;
     &lt;option&gt;2008&lt;/option&gt;
     &lt;option&gt;2007&lt;/option&gt;
     &lt;option&gt;2006&lt;/option&gt;
     &lt;option&gt;2005&lt;/option&gt;
     &lt;option&gt;2004&lt;/option&gt;
     &lt;option&gt;2003&lt;/option&gt;
     &lt;option&gt;2002&lt;/option&gt;
     &lt;option&gt;2001&lt;/option&gt;
     &lt;option&gt;2000&lt;/option&gt;
     &lt;option&gt;1999&lt;/option&gt;
     &lt;option&gt;1998&lt;/option&gt;
     &lt;option&gt;1997&lt;/option&gt;
     &lt;option&gt;1996&lt;/option&gt;
     &lt;option&gt;1995&lt;/option&gt;
     &lt;option&gt;1994&lt;/option&gt;
     &lt;option&gt;1993&lt;/option&gt;
     &lt;option&gt;1992&lt;/option&gt;
     &lt;option&gt;1991&lt;/option&gt;
     &lt;option&gt;1990&lt;/option&gt;
     &lt;option&gt;1989&lt;/option&gt;
     &lt;option&gt;1988&lt;/option&gt;
     &lt;option&gt;1987&lt;/option&gt;
     &lt;option&gt;1986&lt;/option&gt;
     &lt;option&gt;1985&lt;/option&gt;
     &lt;option&gt;1984&lt;/option&gt;
     &lt;option&gt;1983&lt;/option&gt;
     &lt;option&gt;1982&lt;/option&gt;
     &lt;option&gt;1981&lt;/option&gt;
     &lt;option&gt;1982&lt;/option&gt;
   &lt;/select&gt;
  &lt;INPUT TYPE="submit" value="Send" name="submit" /&gt;
  &lt;/FORM&gt;
  &lt;?
  } else { 
  echo "You chose: " . " ". $month . " ".$day . ", ". $yr;
  }
  ?&gt;
  </code></pre>