Wpform get the selected date inside DatePicker and disable a selected time

218 Views Asked by At

I need For example when clicked a specific date (July 13) the dropdown time have to show a specifi range of hours: (now show from 10am to 6pm and i would like to show 10am to 5pm)

with this function i can only get today, any suggestion would be appreciated

function wpf_dev_check_date() {
?>
<script>
    jQuery(function($) {
  
                    // Only display the message if the form ID is 1899 and the field ID is 72
        window.wpforms_1256_4 = window.wpforms_1256_4 || {};
        window.wpforms_1256_4.datepicker = {
            mode: "single",
            onClose: function(selectedDates, dateStr, instance) {
                var today = new Date(); 
                if (selectedDates[0].toLocaleDateString("en-US") == today.toLocaleDateString("en-US")) {
                    alert( 'Custom Message: You have selected todays date' );
                    this.clear();
                }
  
            }
  
        }
    });
</script>
<?php
}
add_action( 'wpforms_wp_footer', 'wpf_dev_check_date', 10 );
0

There are 0 best solutions below