FreshSuperCool.com

July 10, 2008

How to disable previous days in DHTML JS Calendar

Filed under: web 2.0 — Tags: — taewoo @ 1:32 pm

If you are using the DHTML JS Calendar and is trying to disable the previous days, by doing so


function dateRange(date) {
var now = new Date();
return (date.getTime() <= now.getTime() )
}

Calendar.setup({
inputField  : “calendar”,
ifFormat    : “%m/%d/%Y %H:%M %p”,
dateStatusFunc : dateRange,
showsTime   : true,
timeFormat  : “12″
});

you’ll notice that, you can’t CHOOSE any of the future dates.

The solution is from here, but i’ll repost. Edit your downloaded version of “calendar.js” and change as follows

(line 578)
Calendar.cellClick = function(el, ev) {


(line 592)
cal.date.setDateOnly(el.caldate);
date = cal.date;
if (date) {
Calendar.removeClass(cal.currentDateEl, “selected”);
Calendar.addClass(el, “selected”);
closing = (cal.currentDateEl == el);

if (!closing) {
cal.currentDateEl = el;
}
}

Share/Save/Bookmark

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment