Home / Admin / Limiting Options for the Date / Time Field
Duplicate Snippet

Embed Snippet on Your Site

Limiting Options for the Date / Time Field

This snippet will disable any future date in your date picker. You'll need to update the snippet to change the form and field IDs (wpforms_323_4). If you need help in finding these IDs, please review the tutorial here: https://wpforms.com/developers/how-to-locate-form-id-and-field-id/.

20+
Code Preview
php
<?php
/** 
Don't allow date to be selected after maxDate 
Original doc link: https://wpforms.com/developers/customize-the-date-time-field-date-options/ 
For support, please visit: https://www.facebook.com/groups/wpformsvip
*/
function wpf_dev_limit_date_picker() { 
   ?> 
   <script type="text/javascript"> 
	   
	  // Run this snippet on form ID 323 and field ID 4 
      window.wpforms_323_4 = window.wpforms_323_4 || {};
      window.wpforms_323_4.datepicker = { 
        disableMobile: true, 
        // Don't allow users to pick past dates 
        maxDate: new Date(), 
      } 
   </script> 
 
   <?php 
} 
add_action( 'wpforms_wp_footer_end', 'wpf_dev_limit_date_picker', 10 );

Comments

Add a Comment