Title: Minimum birthdate age
Last modified: August 30, 2016

---

# Minimum birthdate age

 *  [Christiaan](https://wordpress.org/support/users/christiaan-grob/)
 * (@christiaan-grob)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/)
 * Is there an way to set an minimum age for the birthdate?
    Everyone who register
   needs to have an age from 16+
 * So now select up to the year 1999 and after december it needs to be the year 
   2000
 * [https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/](https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/)

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

 *  [Dimitris Kalliris](https://wordpress.org/support/users/fovoc/)
 * (@fovoc)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654827)
 * Hey there and thanks for this awesome plugin.
    I second this … a minimum option
   would be great!
 * Cheers!
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654877)
 * You can do it using javascript. I don’t know another way to do this.
 *  [Dimitris Kalliris](https://wordpress.org/support/users/fovoc/)
 * (@fovoc)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654878)
 * Hey there,
 * do you mean by hiding values in front end?
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654881)
 * You need to check the 3 dropdown boxes (day, month and year) and update them 
   according to your needs.
 *  [Dimitris Kalliris](https://wordpress.org/support/users/fovoc/)
 * (@fovoc)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654886)
 *     ```
       $('select#field_276_year option').each(function(){
        var legit_year = GetTodayYear() - 18;
        var current = $(this);
        if ( current.val() > legit_year ) {
         current.remove();
        }
       });
   
       function GetTodayYear() {
        var tdate = new Date();
        var yyyy = tdate.getFullYear();
        return yyyy;
       }
       ```
   
 * For anyone interested, that’s my tiny workaround handling the year of birth. 
   Keep in mind to change `#field_276_year` with your corresponding field ID.
 * Cheers,
    Dimitris
 *  [mln83](https://wordpress.org/support/users/mln83/)
 * (@mln83)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654898)
 * Great stuff [@fovoc](https://wordpress.org/support/users/fovoc/),
 * Just what I was looking for. I am guessing the field ID is the one visible when
   editing the Field from the backend:
    [http://imgur.com/WqmqAwM](http://imgur.com/WqmqAwM)
 * In this case field_id=601
 * In any case I will try your code 🙂
 * Best regards,
    Michael
 *  [mln83](https://wordpress.org/support/users/mln83/)
 * (@mln83)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654899)
 * Works great!
 * Unfortunately, it doesn’t filter for month / day. Probably too advanced.
 * I was wondering about an alternative. Is it possible to check for age after they
   click “Complete Signup”? and deny access if they are below age requirement?
 * Best regards,
    Michael
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654904)
 * I’ve added a new option to birthdate fields. You can now choose a minimum age.
   Hope this help you. Check version 2.4.4.
 *  [mln83](https://wordpress.org/support/users/mln83/)
 * (@mln83)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654905)
 * Hi [@donmik](https://wordpress.org/support/users/donmik/),
 * Thank you very much for adding this to the plugin 🙂
 * Unfortunately, it doesn’t seem to be working on my site:
    [http://somup.com/cDewYlUiS](http://somup.com/cDewYlUiS)
 * I removed the JS code previously posted:
 *     ```
       $('select#field_276_year option').each(function(){
        var legit_year = GetTodayYear() - 18;
        var current = $(this);
        if ( current.val() > legit_year ) {
         current.remove();
        }
       });
   
       function GetTodayYear() {
        var tdate = new Date();
        var yyyy = tdate.getFullYear();
        return yyyy;
       }
       ```
   
 * I am not sure if it needs to be included?
 * Best regards,
    Michael
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654906)
 * Ok, I understand what you want is not allow users to enter invalid birthdates…
   What I did is validate the birthdate with PHP. So when you send the birthdate,
   if the user is less than 18, the page will display an error saying the user must
   be at least 18 and the registration will fail.
 * I will try to update my plugin and see if I can fill the dropdown boxes only 
   with correct birthdates.
 *  [JanDieckmann](https://wordpress.org/support/users/jandieckmann/)
 * (@jandieckmann)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654912)
 * Hello,
 * I would like to have a field where I can choose a date in the past and thought
   the birthday field would make it but there I can’t select the present year. I
   changed to the date selector type and tried to modify the output with the code
   mentioned above for not having the future years, but when I copy it like it is
   into the my theme’s function.php, change the field number and save I get en error
   message and have to recover the function.php.
 * What would be the best way to have a date field wit a range, where I have to 
   pic a date between a given date in the past and today?
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654913)
 * Update to version 2.5, I’ve changed it you can select dates from yesterday now.

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

The topic ‘Minimum birthdate age’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/buddypress-xprofile-custom-fields-
   type.svg)
 * [Buddypress Xprofile Custom Fields Type](https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/)
 * [Active Topics](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/reviews/)

## Tags

 * [age](https://wordpress.org/support/topic-tag/age/)
 * [year](https://wordpress.org/support/topic-tag/year/)

 * 12 replies
 * 5 participants
 * Last reply from: [donmik](https://wordpress.org/support/users/atallos/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/minimum-birthdate-age/#post-6654913)
 * Status: not resolved