function ucDate_getComboValue(controlId, name) { var oCbo = document.getElementById ((controlId != "")?controlId + "_" + name: name); return oCbo.options[oCbo.selectedIndex].value; } function ucDate_getMin(controlId) { return ucDate_getComboValue(controlId, "cboMinute"); } function ucDate_getHour(controlId) { return ucDate_getComboValue(controlId, "cboHour"); } function ucDate_getDay(controlId) { return ucDate_getComboValue(controlId, "cboDay"); } function ucDate_getMonth(controlId) { return ucDate_getComboValue(controlId, "cboMonth"); } function ucDate_getYear(controlId) { return ucDate_getComboValue(controlId, "cboYear"); } function ucDate_getValue(controlId) { return ucDate_buildDate(ucDate_getDay(controlId), ucDate_getMonth(controlId), ucDate_getYear(controlId)); } function ucDate_buildDate(day, month, year) { if (day == "" || month == "" || year == "") { return null; } month--; var oDate = new Date(); oDate.setDate(1); // to stop month roll-over issue below oDate.setYear(year); oDate.setMonth(month); oDate.setDate(day); if (oDate.getDate() == day && oDate.getMonth() == month && oDate.getFullYear() == year) { return oDate; } else { return null; } } function ucDate_toString(date) { if (date == null) return ""; var sMonths = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); return date.getDate() + "-" + sMonths[date.getMonth()] + "-" + date.getFullYear(); } function ucDate_validate(description, controlId, mandatory, optional, minDay, minMth, minYr, maxDay, maxMth, maxYr) { var iDay = ucDate_getDay(controlId); var iMth = ucDate_getMonth(controlId); var iYr = ucDate_getYear(controlId); if (iDay == "" && iMth == "" && iYr == "") { if (mandatory) { alert("Please specify a value for" + " " + description); return false; } else if (optional) { return confirm("You have not selected a VALID value for" + " " + description + ". " + "Click OK to proceed anyway, or Cancel to go back and enter a valid value for" + " " + description); } } else { if (iDay == "" || iMth == "" || iYr == "") { alert("Please specify a value for all parts of" + " " + description + "\n" + "(i.e. day, month and year)"); return false; } else { var oDate = ucDate_buildDate(iDay, iMth, iYr); if (oDate == null) { alert("You have entered an invalid value for" + " '" + description + "'."); return false; } else { if (minDay > 0) { var oMinDate = ucDate_buildDate(minDay, minMth, minYr); if (oDate < oMinDate) { alert("'" + description + "' " + "cannot be before" + " " + ucDate_toString(oMinDate)); return false; } } if (maxDay > 0) { var oMaxDate = ucDate_buildDate(maxDay, maxMth, maxYr); if (oDate > oMaxDate) { alert("'" + description + "' " + "cannot be after" + " " + ucDate_toString(oMaxDate)); return false; } } } } } return true; }