Disable day,year,month?

Moderators: Calcifer, slothy

Disable day,year,month?

Postby pinguino » Mon Jul 31, 2006 10:03 am

Hi, sorry for my bad english. I want to know if is possible to disable a range of day, month or year in your calendar.


if i want to use calendar to choice a date between:

20/08/2006 - 28/08/2006?

Posts: 7
Joined: Mon Jul 31, 2006 10:00 am

Postby Batalf » Mon Jul 31, 2006 11:53 am

Hello pinguino,

Welcome to the forum :D

No, unfortunately, that's not possible at the moment.

But it's a very good suggestion and I would try to implement that feature into the calendar as soon as possible.
Site Admin
Posts: 2160
Joined: Sat Oct 22, 2005 9:38 pm

Postby pinguino » Mon Jul 31, 2006 12:34 pm

Ok thank you. This feature is very important when you must choice a date of departure and a date of arrival in a form, ecc.....

Posts: 7
Joined: Mon Jul 31, 2006 10:00 am

Postby flash » Tue Aug 29, 2006 11:41 pm

Yes, it will be great to have that.
Posts: 10
Joined: Wed Jun 07, 2006 5:55 pm

Postby flash » Tue Sep 26, 2006 5:13 pm

This might give you a clue how to disable the dates. I am still testing.

//Calendar.css addition
#calendarDiv .disableDay{ /* Disabled days in the calendar */

//New methods in calendar.js
// For adding days to the date object.
function addDaysToDate(date,days){

var t = date.getTime() + (days * 1000 * 60 * 60 * 24)
return new Date(t);

//disabling four days after current date.
var disDate = addDaysToDate(new Date(), 4);

//To disable the date. Change this date to however you want the logic to be.
function toDisable(dateObj,date){

var cYear = disDate.getFullYear();
var cMonth = disDate.getMonth()-1;
var cDate = disDate.getDate();
var dateTill = Date.UTC(cYear,cMonth,cDate);
var displayDate = Date.UTC(dateObj.getFullYear(),dateObj.getMonth(),date);

return displayDate < dateTill;

//Find "cell.onclick = pickDate;" in the function writeCalendarContent()
//replace with following.
if (toDisable(d,no)) {
}else {
cell.onclick = pickDate;
Posts: 10
Joined: Wed Jun 07, 2006 5:55 pm

Re: Disable day,year,month?

Postby rafabrasa » Tue Apr 17, 2012 2:17 pm

Hi Flash,

Thanks for the code for disabling days in the past. I´ve been using in my web site but it seems to have a bug when the year is a leap year. On march 31 on a leap year, when you open the calendar it disables April 1st. I tried modifying the code to fix this but couldn´t get it done right.

You mentioned in your post you were still testing the code. Have you found this problem I described? would you have a fix for this?

Thank you very much for your help!

Posts: 1
Joined: Wed Feb 08, 2012 6:21 pm

Return to Calendar script questions

Who is online

Users browsing this forum: No registered users and 2 guests