title: Calculate age in years on date select from jquery datepicker
body: <p>I would like to calculate the age of the user as soon as he selects a date from jquery datepicker.</p>
  
  <pre><code>$(document).ready(function() {
    $( "#nominee_one_dob" ).datepicker({
      changeMonth: true,
      changeYear: true,
      dateFormat: 'yy-mm-dd',
  
      onSelect: function (date) {
          var dob = Date.parse(date);
          if (dob.addYears(18) &lt; Date.today())
          {
              alert("Under 18");
          }
          else
          {
              alert(" Over 18");
          }
      }
  
    });
  </code></pre>
  
  <p>I am able to get the date selected when i <code>alert(date)</code> but I am not getting anything from the further code.</p>
  
  <p>Please help.</p>