'limiting the date-picker to be prior to certain number of years

I need to implement a modification in the WPForms in a site, the user could not select a date after 18 years back from now. The idea is to limit people younger than 18 years old to apply in job openings. I implemented this easily in PHP, but not sure how to achieve this using the plugin.

SOLUTION: I added a code snippet pointing to the form ID, as follows:

 /**
 * Show dates from 18 years ago day and backwards - prueba
 *
 * @link https://wpforms.com/developers/customize-the-date-time-field-date-options/
 * above, the link to the original code I used
 */

function wpf_limit_date_picker() {
    ?>
    <script type="text/javascript">
        var d = new Date();
        window.wpforms_datepicker = {
            disableMobile: true,
            // Don't allow users to pick dates less than 18 years ago
            maxDate: d.setDate(d.getDate() - 6574),
        }
    </script>
    <?php
}
add_action( 'wpforms_wp_footer_end', 'wpf_limit_date_picker', 30 );

"-6574" means the number of days back from now to a date tha't 18 years past.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source