skip to Main Content

**I need to update the function.php file so that its showing 99 years not just 20 years, I am running Bizberg theme

Tried this, and it failed to give me an extended range, the issues is the scroll bar still only allows 20 years, I need99**

function extend_date_of_birth_range() {
    ?>
    <script>
        jQuery(function($) {
            var currentYear = new Date().getFullYear();
            var startYear = currentYear - 99;
            var endYear = currentYear - 10;

            // Replace "billing_date_of_birth" with the ID or name of your date of birth field
            $('#billing_date_of_birth').datepicker('option', {
                yearRange: startYear + ':' + endYear
            });
        });
    </script>
    <?php
}
add_action('wp_footer', 'extend_date_of_birth_range');

2

Answers


  1. You can use like this:

    var dateRange = '"'+startYear+' : '+endYear+'"';
    

    and put the "dateRange" variable as below:

    // Replace "billing_date_of_birth" with the ID or name of your date of birth field
    $('#billing_date_of_birth').datepicker('option', {
         yearRange: dateRange
    });
    
    Login or Signup to reply.
  2. Add this function in function.php file, hope this will help

    <?php 
    function extend_date_of_birth_range() {
        ?>
        <script>
            jQuery(function($) {
                var currentYear = new Date().getFullYear();
                var startYear = currentYear - 99;
                var endYear = currentYear - 10;
                var dateRange = '"'+startYear+' : '+endYear+'"';
    
                // Replace "billing_date_of_birth" with the ID or name of your date of birth field
                $('#billing_date_of_birth').datepicker('option', {
                    yearRange: dateRange
                });
            });
        </script>
        <?php
    }
    add_action('wp_footer', 'extend_date_of_birth_range');
    ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search