[script language = "Javascript"] //CLIENT SIDE AUXILIARY FUNCTIONS /*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--* * PURPOSE: Test if a particular year is a leap year * DOCUMENTED AT: http://www.geocities.com/matth3wbishop/eg/asp/fnDatePicker.doc * DEPENDENCIES: [none] * SOURCE CODE: http://www.geocities.com/matth3wbishop/eg/asp/fnDatePicker.txt * STATUS: working --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*/ function fnIsLeapYear(iYear) { var regYear = /\d{4}/gi; var bIsLeapYear = new Boolean(); if ((iYear % 4) == 0) { if ((iYear % 100) != 0) {bIsLeapYear = true;} } /* if */ return bIsLeapYear; } /* fnIsLeapYear */ /*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--* * PURPOSE: to keep the HIDDEN html element which is attached to the three date boxes in synch when the values of any of those boxes change * DOCUMENTED AT: http://www.geocities.com/matth3wbishop/eg/asp/ * STATUS: working --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*/ function fnSynchronizeHidden(sName) { var lbxDay = eval("document.forms[0]." + sName + "day"); var lbxMonth = eval("document.forms[0]." + sName + "month"); var lbxYear = eval("document.forms[0]." + sName + "year"); var iDay = lbxDay.options[lbxDay.selectedIndex].value; var iMonth = lbxMonth.options[lbxMonth.selectedIndex].value; var iYear = lbxYear.options[lbxYear.selectedIndex].value; var hidden = eval("document.forms[0]." + sName); //alert(iDay + " " + iMonth + " " + iYear + " " + fnIsLeapYear(iYear)); if ((iDay == "null") || (iMonth == "null") || (iYear == "null")) {hidden.value = "null";} else { iMonthVal = parseInt(iMonth) + 1; hidden.value = iMonthVal + "/" + iDay + "/" + iYear; //alert(hidden.value); } } /* fnSynchronizeHidden */ /*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--* * PURPOSE: To prevent the selection of illegal dates in the datepicker eg 'Feb 30 1999' * DOCUMENTED AT:(203.62.157.45) http://www.geocities.com/matth3wbishop/eg/asp/ * SOURCE: (203.62.157.45) http://www.geocities.com/matth3wbishop/eg/asp/ * STATUS: working --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*/ function fnStopIllegalDates(sName) { var lbxDay = eval("document.forms[0]." + sName + "day"); var lbxMonth = eval("document.forms[0]." + sName + "month"); var lbxYear = eval("document.forms[0]." + sName + "year"); var iDay = lbxDay.options[lbxDay.selectedIndex].value; var iMonth = lbxMonth.options[lbxMonth.selectedIndex].value; var iYear = lbxYear.options[lbxYear.selectedIndex].value; //alert(iDay + " " + iMonth + " " + iYear + " " + fnIsLeapYear(iYear)); if ((iDay > 29) && (iMonth == 1)) { lbxDay.options[0].selected = true; } if ((iDay > 28) && (iMonth == 1) && (fnIsLeapYear(iYear) == false)) { lbxDay.options[0].selected = true; } if (((iMonth == 3) || (iMonth == 5) || (iMonth == 8) ||(iMonth == 10)) && (iDay > 30)) { lbxDay.options[0].selected = true; } } /* fnLegalDate() */ [/script] [script language = "Jscript" runat = "Server"] /*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--* * FUNCTION: fnDatePicker() * PURPOSE: to provide a simple element for selecting date values * DOCUMENTED AT: http://www.geocities.com/matth3wbishop/eg/asp/ * DEPENDENCIES: * STATUS: working --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*/ function fnDatePicker(sName, sValue, sYearRange, bHasBlanks) { var dToday = new Date(); var sReturn = new String(); var regParseYear = /(\d{4})\D{1,2}(\d{4})/gi; var iYearA; //***Values parsed from the Year Range var iYearB; //***Defaults if (sValue == null) { dValue = dToday; } /* if */ else { dValue = new Date(sValue); } if (sName == null) { sName = "DatePicker"; } /* if */ if (bHasBlanks == null) { bHasBlanks = true; } /* if */ if (sYearRange != null) { if (regParseYear.test(sYearRange) == false) { iYearA = 1990; iYearB = 2100; } /* if */ else { iYearA = parseInt(sYearRange.replace(regParseYear, "$1")); iYearB = parseInt(sYearRange.replace(regParseYear, "$2")); } /* if, else Bad Format*/ } else { iYearA = 1990; iYearB = 2100; } /* if, else Range is Null*/ //***The Day Box sReturn += "\n"; //***The Month Box sReturn += "\n"; //***The Year Box sReturn += "\n"; sReturn += "\n"; return sReturn; } /* fnDatePicker */ [/script]