I've made a custom date picker using jQuery UI: http://jsfiddle.net/u8fVj/
$("#input_custom_date").datepicker({
numberOfMonths: 2,
beforeShowDay: function(date) {
//Get today's date
var today = new Date();
today.setHours(0,0,0,0);
if (today.getDay() == 4 || today.getDay() == 5 || today.getDay() == 6) {
//If today is Wednesday, Thursday, Friday don't allow Sunday to be selectable until the next week on Sunday.
var disabledDate = new Date(today||new Date());
disabledDate.setDate(disabledDate.getDate() + (0 - 1 - disabledDate.getDay() + 7) % 7 + 1);
return [(date > today && date.getDay() == 0 && date.toString() != disabledDate.toString()), ''];
}else if(today.getDay() == 0){
//If today is Sunday, don't allow today to be selectable.
var disabledDate = today;
var curr_date = date.getDate();
var curr_month = date.getMonth();
var curr_year = date.getFullYear();
var dDate = new Date(curr_year, curr_month, curr_date);
return [(date > today && date.getDay() == 0 && dDate.toString() != disabledDate.toString()), ''];
}else{
//Everything is fine, allow all Sundays to be selectable
var day = date.getDay();
return [(date > today && day == 0), ''];
}
}
});
Right now the user should only be able chose dates on a Sunday. It needs to check and see if today's date is a Wednesday, Thursday, or Friday before the upcoming Sunday, and if it is, the date picker should disable the upcoming Sunday. Likewise, if today's date is a Sunday, it should disable today in the date picker.
However, instead of only Sunday being selectable, I need to change the date picker to only allow Monday and Tuesday to be selectable. If today's date is Thursday, Friday, or Saturday, it should disable the upcoming Monday and Tuesday. If today is a Monday it should disable both Monday and Tuesday for the current week. If today's date is Tuesday it should only disable today's date.
Also, I would need to ability to throw in specific dates for holidays to be disabled, which could be hard-coded.
Not sure how to go beyond what I have now and would appreciate any help. I've been trying to get this working and can't get the logic to work out.