Home / Admin / Allow only specific days of the month in all WPForms date pickers
Duplicate Snippet

Embed Snippet on Your Site

Allow only specific days of the month in all WPForms date pickers

If you only want users to select certain days of the month in the Date Picker, you can use the snippet below.

<10
Code Preview
php
<?php
/**
 * Allow only specific days of each month in all WPForms date pickers.
 *
 * @link https://wpforms.com/developers/customize-the-date-time-field-date-options/
 */
function wpf_dev_only_selected_days() {
    ?>
    <script type="text/javascript">
        window.wpforms_datepicker = {
            disableMobile: true,
            disable: [
                function(date) {
                    var day = date.getDate();
                    // Disable every day that is NOT the 5th or 20th
                    if (day !== 5 && day !== 20) {
                        return true;  // disabled
                    }
                    return false;    // keep the 5th and 20th enabled
                }
            ]
        };
    </script>
    <?php
}
add_action( 'wpforms_wp_footer_end', 'wpf_dev_only_selected_days', 30 );

Comments

Add a Comment