/* startGreaterThanEndDate2() * Author: David Hirsch * Creation Date: 3/21/02 * Parameters: * startdate - should be a Javascript Date object * enddate - should be a Javascript Date object * Return Value: * true - if the startdate is later than the enddate. * false - if the startdate is earlier or the same as the enddate */ function startGreaterThanEndDate2(startdate, enddate) { var startTime = startdate.getTime(); var endTime = enddate.getTime(); if (startTime > endTime){ return true; } return false; } /* verifyDatePairWithFormat() * Author: David Hirsch * Creation Date: 3/27/02 * Parameters: * fieldName1(2) - name for the first(second) date field, used in alert box * name1(2) - qualified name prefix for the date fields. * Typically this is of the form formname.myprefix * Like the other date functions it assumes the names * follow the pattern DateField * required1(2) - is this date field required. If so and there is no * date then it will return false * alert1(2) - if true put up an alert box if there is an error * for this field * greaterthancheck - if true check whether the first date is greater * than the second date. If so return false. * alertgreaterthan - if true put up an alert box if the greater than * date check returns true * alertFrag - ok this is ugly but resource bundling forces the * issue. This fragment will be consed as follows * fieldName2 + " " + alertFrag + " " + fieldName1 + "." * format - date format sring used to parse date field into * its constituent parts * Return Value: * true - based on the arguments, the specified dates are valid * false - based on the arguments, the specified dates are invalid * Comments: Currently the format pattern is not passed in and is fixed by * this function. Note the format is used in multiple locations so we may want * to centralize it to one location? */ function verifyDatePairWithFormat(fieldName1, name1, required1, alert1, fieldName2, name2, required2, alert2, greaterthancheck, alertgreaterthan, alertFrag, format) { var date1, date2; var result = true; date1 = extractDateFromDateField(fieldName1, name1, format, required1, alert1); if (date1 == false) return false; date2 = extractDateFromDateField(fieldName2, name2, format, required2, alert2); if (date2 == false) return false; if (greaterthancheck == true) { //test greater than var dateText1 = eval('document.' + name1 + 'DateField.value'); var theDate1 = getDateFromFormat(dateText1, format); var dateText2 = eval('document.' + name2 + 'DateField.value'); var theDate2 = getDateFromFormat(dateText2, format); var testresult = startGreaterThanEndDate2(theDate1, theDate2); //alert("greater than test returned: " + testresult); if (testresult == true) { if (alertgreaterthan == true) { alert(fieldName2 + " " + alertFrag + " " + fieldName1 + "."); } result = false; }; } return result; } /* initStartandEndDates * Author: David Hirsch * Creation Date: 3/21/02 * Parameters: * startdate - should be a Javascript Date object * enddate - should be a Javascript Date object * prefix - prefix used with naming date related fields * format - date format string used to format date into a string * Comments: This will set the startdatefield to the startdate and the enddate * field to the end date. Note: the individual component date fields are not * set by this function. They get set when the form is saved. * Currently the format pattern is not passed in and is fixed by * this function. Note the format is used in multiple locations so we may want * to centralize it to one location? */ function initStartandEndDatesWithFormat(startDate, endDate, prefix, format) { //alert("Format string2 is " + format); var startDateTxt = formatDate(startDate, format); var endDateTxt = formatDate(endDate, format); var sfname = eval(prefix + "StartDateField"); var efname = eval(prefix + "EndDateField"); var isfname = eval(prefix + "InitStartDateField"); var iefname = eval(prefix + "InitEndDateField"); sfname.value = startDateTxt; efname.value = endDateTxt; //cache init values so can see if changed isfname.value = startDateTxt; iefname.value = endDateTxt; }