Viewing 12 replies - 1 through 12 (of 12 total)
  • Hey there and thanks for this awesome plugin.
    I second this … a minimum option would be great!

    Cheers!

    Plugin Author donmik

    (@atallos)

    You can do it using javascript. I don’t know another way to do this.

    Hey there,

    do you mean by hiding values in front end?

    Plugin Author donmik

    (@atallos)

    You need to check the 3 dropdown boxes (day, month and year) and update them according to your needs.

    $('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

    Great stuff @fovoc,

    Just what I was looking for. I am guessing the field ID is the one visible when editing the Field from the backend:
    https://imgur.com/WqmqAwM

    In this case field_id=601

    In any case I will try your code ??

    Best regards,
    Michael

    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

    (@atallos)

    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.

    Hi @donmik,

    Thank you very much for adding this to the plugin ??

    Unfortunately, it doesn’t seem to be working on my site:
    https://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

    (@atallos)

    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.

    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

    (@atallos)

    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.