WPForms gives us the ability to disable selection of dates in the past however if you want to restrict dates in the future there isn't an option available for the field in the user interface.
That's not impossible to do but you will have to use a bit of jQuery to achieve that. And we will show you how.
WPForms can be easily customized to your specific needs using jQuery, and in this case we will do the same - use a snippet of jQuery code to customize the date / time field.
For this certain use case we are limiting dates in the future, it is particularly helpful in cases where you have a Date of Birth option and you don't want anybody to select a future date.
Interestingly WPForms provides these snippets on their developer documentations but we noticed that it doesn't actually work well where you want to apply the settings only to a one specific field in your form.
Don't allow Dates to be selected after a certain date
/** * Don't allow date to be selected after maxDate * * @link https://wpforms.com/developers/customize-the-date-time-field-date-options/ */ function wpf_dev_limit_date_picker() { ?> <script type="text/javascript"> window.wpforms_datepicker = { // Don't allow users to pick dates after Dec 31, 2025 maxDate: new Date( '2025-12-31' ) } </script> <?php } add_action( 'wpforms_wp_footer_end', 'wpf_dev_limit_date_picker', 10 );Using the `new Date( '2025-12-31' )` in JavaScript we tell WPforms to not allow date after 12 December 2025 to be selected.
/** * Don't allow date to be selected after maxDate * * @link https://wpforms.com/developers/customize-the-date-time-field-date-options/ */ function wpf_dev_limit_date_picker() { ?> <script type="text/javascript"> window.wpforms_datepicker = { // Don't allow users to pick any dates after today maxDate: new Date() } </script> <?php } add_action( 'wpforms_wp_footer_end', 'wpf_dev_limit_date_picker', 10 );
Limit Date restriction only for a specific field
/** * Don't allow date to be selected after maxDate * * @link https://wpforms.com/developers/customize-the-date-time-field-date-options/ */ function wpf_dev_limit_date_picker() { ?> <script type="text/javascript"> window.wpforms_2238_19 = { // Don't allow users to pick any dates after today datepicker: { maxDate: new Date() } } </script> <?php } add_action( 'wpforms_wp_footer_end', 'wpf_dev_limit_date_picker', 10 );