jQuery UI Datepicker - Disable specific days

前端 未结 6 2124
予麋鹿
予麋鹿 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:24

     var unavailableDates = ["19-8-2014","14-9-2014"];
    
     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 });
    

    Live Demo: http://jsfiddle.net/vfod0krm/

提交回复
热议问题