title: Validation against birthdate issue using JQuery
body: <p>I have this app that has a javascript datepicker, the datepicker puts the birth date into a hidden field, the value of the hidden field is then compared with a date to see if it is over 18 years old, if not it will throw an error message. The problem I'm having is that it seems my script is only taking into account the year, and not including the month and day in that equation. Here is the script that does the comparison:</p>
  
  <pre><code>(function ($) {
  $.validator.addMethod('minage',
      function (value, element, params) {
          if (this.optional(element)) {
              return true;
          }
          // parseDate throws exception if the value is invalid
          try {
              var valDate = jQuery.datepicker.parseDate('m/dd/yy', value);
          } catch (e) {
              return false;
          }
          var today = new Date();
              var mindate = new Date(today.getFullYear() - params, today.getMonth(), today.getDay(), 0, 0, 0, 0);
          if (valDate &lt;= mindate) {
              return true;
          }
          else {
              return false; 
          }
      }
  );
  
  $.validator.unobtrusive.adapters.addSingleVal('minage', 'tooyoung');
  })(jQuery);
  </code></pre>
  
  <p>Lets say i have someone who turned 18 today, i need it to compare the birthdate to todays date and say ok, they are now 18, and if they select tomorrows day, it will throw an error. Anyone know where i'm going wrong?</p>