Dates and Calendars - Calendar Date Picker

for Win/IE5.5+, Netscape 6+, Mozilla 1.1+, Firefox, Opera 7+

This is a highly configurable date picker that allows you to specify date ranges and formats.
function showCal() takes 6 arguments:
showCal(month,year,formField,dateSpan,weekends,dateFormat)

Enter a Date (MM/DD/YYYY):
Current month and year, document.forms['myDate'].DATE1, dateSpan = 5 (all dates), weekends = true, dateFormat = 2 (mm/dd/yyyy)

Enter a Date (DD/MM/YY):
Month = 1 (February), year = 2001, document.forms['myDate'].DATE1, dateSpan = 4 (all past dates NOT including today), weekends = false, dateFormat = 6 (dd/mm/yy)

<form name="myDate">
Enter a Date (MM/DD/YY): <input type="text" name="DATE1">
<img src="images/calendar.gif" onclick="showCal('','',document.forms['myDate'].DATE1,5,true,2)">

Enter a Date (DD/MM/YY): <input type="text" name="DATE2">
<img src="images/calendar.gif" onclick="showCal('1','2001',document.forms['myDate'].DATE2,4,false,6)">

</form>

Month is a number between 0 and 11, with 0 = January and 11 = December.

Year is a 4 digit number

If you leave the month and year empty it will default to the current month and year.

formField is the field the date will be entered into.

dateSpan is a number representing which dates should be clickable. It does not include weekends.
0 = no dates
1 = all past dates up to and including today
2 = all future dates starting with today
3 = all future dates NOT including today
4 = all past dates NOT including today
5 = all dates

weekends is a true/false boolean that indicates if weekend dates should be clickable. Produces no effect when dateSpan = 0;

dateFormat corresponds to the formats defined in function dateFormats().
0 = mmddyy
1 = mmddyyyy
2 = mm/dd/yyyy
3 = mm/dd/yy
4 = yyyymm
5 = ddmmyy
6 = dd/mm/yy
7 = ddmmyyyy
8 = dd/mm/yyyy

It seems like overkill doesn't it?. But I wrote it for a site that uses a wide variety of date formats and ranges and I didn't want to have a different calendar script for each format.

You can combine this with the date validating and formatting scripts








PXL8 2004