Title: Date Validation
Last modified: December 23, 2021

---

# Date Validation

 *  Resolved [mpbaweb](https://wordpress.org/support/users/mpbaweb/)
 * (@mpbaweb)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/date-validation-4/)
 * Hi
    I have a dropdown that selects a category one of Adult|Junior|Senior and 
   a date box for date of birth. I’d like to add a validation that checks: If Category
   =Adult then DOB must be less than or equal to Today()-18years If Category=Junior
   then DOB must be more than Today()-18years If Category=Senior then DOB must be
   less than or equal to Today()-60years
 * Is this possible?
 * Many thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/date-validation-4/#post-15299188)
 * Hello [@mpbaweb](https://wordpress.org/support/users/mpbaweb/)
 * My apologies, I did not receive the notification about your forum entry.
 * I’ll try to respond to your question with a hypothetical example:
 * Assuming the category field is the fieldname1 and the date field is the fieldname2.
 * Please, insert a calculated field in the form, configured as hidden, and enter
   the following equation:
 *     ```
       (function(){
       var min_date = '-18y';
       if(fieldname1 == 'Adult') min_date = '-18y';
       if(fieldname1 == 'Senior') min_date = '-60y';
   
       getField(2).set_minDate(min_date);
       })()
       ```
   
 * Best regards.
 *  Thread Starter [mpbaweb](https://wordpress.org/support/users/mpbaweb/)
 * (@mpbaweb)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/date-validation-4/#post-15300797)
 * Thank you. That’s perfect. Solved
    -  This reply was modified 4 years, 4 months ago by [mpbaweb](https://wordpress.org/support/users/mpbaweb/).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Date Validation’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [mpbaweb](https://wordpress.org/support/users/mpbaweb/)
 * Last activity: [4 years, 4 months ago](https://wordpress.org/support/topic/date-validation-4/#post-15300797)
 * Status: resolved