I've updated my code here. I've put the range inside the unavailableDays function which I need to reference in beforeShowDays in datepicker to disable those days.
function unavailableDays(date) {
function createDateRange(first, last) {
var date = [];
for(var j = first; j < last; j.setDate(j.getDate() + 7))
dates.push(new Date(j.getTime()));
return date;
}
var disabledDays = createDateRange(new Date("1978-08-10"), new Date("1978-11-05"));
//date array to be disabled
var disabledDays = ["1963-3-10", "1963-3-17", "1963-3-24", "1963-3-31", "1965-9-18"];
var yy = date.getFullYear(), mm = date.getMonth(), dd = date.getDate();
for (i = 0; i < disabledDays.length; i++) {
if($.inArray(yy + '-' + (mm+1) + '-' + dd,disabledDays) != -1 || new Date() < date) {
return [false];
} }
return [true]; }
function createDateRange(first, last) {
var dates = [];
for(var i = first; i < last; i.setDate(i.getDate() + 7))
dates.push(new Date(i.getTime()));
return dates;
}
var disabledDays = createDateRange(new Date("1978-08-10"), new Date("1978-11-05"));
disabledDays
array. You can also use the createDateRange
function within the unavailableDays
function, but by doing it this way you have two advantages: 1. you don't have to modify your (working) code. 2. It stores the dates, so they won't have to be generated each time you open the datepicker - Jesse van Assen 2012-04-08 08:36