Graying out a specific date with jQuery UI doesn't work

Viewed 41

With the code below, I'm trying to gray out 21/12/2020 because we don't ship until Tuesday(22/12/2020). I cannot find what is wrong in the code below. Please point out the error in the code that might be causing it not to work.

<script>
    jQuery(document).ready( function() {
        jQuery(function() {
            jQuery("#ship_date").datepicker( {
            var minDate;
                // get current date
                var d = new Date();
                var month = d.getMonth()+1;
                var day = d.getDate();
                var current_date = (month<10 ? '0' : '') + month + '/' + (day<10 ? '0' : '') + day + d.getFullYear() + '/'; 
    
                if (current_date < new Date(11, 22, 2020) {
                    minDate = new Date( 11, 22, 2020 );
                } else {
                    minDate = +1;
                }
                maxDate: '+2M',
                beforeShowDay: jQuery.datepicker.noWeekends
            } );
        });
    });
</script>
1 Answers

UPDATED the answer as per request from PKTG:

<script>
      $( function() {
        var cuttoffdate = new Date(2020,11, 22);
        $( "#ship_date" ).datepicker(
        {
                    maxDate: '+2M',
                     beforeShowDay: function (date) {
                        show = true;
                        if (date.getDay() === 0 || date.getDay() === 6) { show = false; }
                        if(date<cuttoffdate) { show=false;};
                        var display = [show, '', (show) ? '' : 'Not available'];
                        return display;
                    }
                }
        );
      } );

</script>
Related