jQuery - Datepicker - Disable Specific Dates

You can disable specific dates with the jQuery Datepicker using the beforeShowDay event.
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 });

 

Note: iDate in the last line is the name of the HTML form input element.

To see a working example with some more features please see the jsFiddle example: HERE
 
posted @ 2012-09-07 16:31  Lux.Y  阅读(424)  评论(0)    收藏  举报