JQuery : UI Datepicker Enable Specific Dates



$(document).ready(function () {
   
var availableDates = ["4-5-2013","27-5-2013","15-5-2013"];

function available(date) {
 dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
 console.log(dmy+' : '+($.inArray(dmy, availableDates)));
 if ($.inArray(dmy, availableDates) != -1) {
return [true, "","Available"];
 } else {
return [false,"","unAvailable"];
 }
}

$('#start_date').datepicker({
dateFormat: "M d, yy",
numberOfMonths: 4,
minDate: 0,
beforeShowDay: available
});


});


source: http://stackoverflow.com/questions/7709320/jquery-ui-datepicker-enable-only-specific-days-in-array

No comments:

Post a Comment