jQuery UI Datepicker - Disable specific days

前端 未结 6 2137
予麋鹿
予麋鹿 2020-11-29 03:20

Is there any (easy) way to set the jQuery UI Datepicker to disallow selection of specific, predetermined days?

I was able to get this approach working, however, it p

6条回答
  •  悲哀的现实
    2020-11-29 03:39

    Here is a way to disable specific dates from being selected:

    var unavailableDates = ["9-5-2011","14-5-2011","15-5-2011"];
    
    function unavailable(date) {
      dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
      if ($.inArray(dmy, unavailableDates) < 0) {
        return [true,"","Book Now"];
      } else {
        return [false,"","Booked Out"];
      }
    }
    
    $('#iDate').datepicker({ beforeShowDay: unavailable });
    

    Source: jQuery - Datepicker - Disable Specific Dates

提交回复
热议问题