jquery dependency validation
<pre><code>var validator = $("#fullRegForm").validate({
    errorLabelContainer: "#error_container",
    wrapper: "li",
    errorClass: "reg_error",
    rules: {
        fr_birthdate: {
            date: true,
            required: true,
            minimumAge: true
        }, 
        fr_consent: {
          required: function(element) {
              var age = getAge($("#fr_birthdate").val());
              if(age &gt;=13 &amp;&amp; age &lt; 18){
                   $("#reg_consent").show();
              } else {
                  $("#reg_consent").hide();
              }
          }
        }
   },
    messages: {
    fr_birthdate: {
     date: "Please enter a valid date of birth",
     required: "Please enter date of birth",
     minimumAge: "under 13 years old are not allowed"
    }, 
    fr_consent: "13-17 years of age must have a parental consent"
   }
</code></pre>

<p>I uses a container to display errors in the form.. but the message for fr_consent message still displaying even the age input is over 18 years old. I try using the same rules but not using error container and it works perfectly. Did I missed something on my code?</p>

<p>getAge:</p>

<pre><code>function getAge(birthDate) {
    var raw_date = birthDate;
    var dobArr = raw_date.split("/");
    var dob = new Date();
    dob.setFullYear(dobArr[2], dobArr[0]-1, dobArr[1]);

    var now = new Date();

    function isLeap(year) {
    return (((year % 4)==0) &amp;&amp; ((year % 100)!=0) || ((year % 400)==0));
    }

    // days since the birthdate    
    var days = Math.floor((now.getTime() - dob.getTime())/1000/60/60/24);
    var age = 0;
    // iterate the years
    for (var y = dob.getFullYear(); y &lt;= now.getFullYear(); y++){
    var daysInYear = isLeap(y) ? 366 : 365;
        if (days &gt;= daysInYear){
          days -= daysInYear;
          age++;
          // increment the age only if there are available enough days for the year.
        }
    }
    return age;
}
</code></pre>
