<!--
/*
 * Date: 12/28/2001
 * File: FormValidation.js
 * Description: FormValidation.js requires that JSLog.js, 
 *              UtilityFunctions.js, and JSLinkedList.js are 
 *              included in the page; a new JSLog object needs 
 *              to be instanciated upon each pass at checking 
 *              the form.
 *
 * Updated: 01/02/2002
 * Description: Added the FormValidation_checkZip() function.
 */
 
    /*
     * FormValidation() is the constructor to create a instance of this
     * object and will be the interface for the form validation functions.
     */
    function FormValidation() {
        this.checkText = FormValidation_checkText;
        this.checkInteger = FormValidation_checkInteger;
        this.checkDouble = FormValidation_checkDouble;
        this.checkTextArea = FormValidation_checkTextArea;
        this.checkRadio = FormValidation_checkRadio;
        this.checkRadioValue = FormValidation_checkRadioValue;
        this.checkSelect = FormValidation_checkSelect;
        this.checkMultiSelect = FormValidation_checkMultiSelect;
        this.checkSSN = FormValidation_checkSSN;
        this.checkZip = FormValidation_checkZip;
        this.checkPhoneNumber = FormValidation_checkPhoneNumber;
        this.checkYear = FormValidation_checkYear;
        this.checkBirthDate = FormValidation_checkBirthDate;
        this.checkPastDueDate = FormValidation_checkPastDueDate;
        this.checkDateLessThan = FormValidation_checkDateLessThan;
        this.checkDate = FormValidation_checkDate;
        this.checkIndexOutOfBounds = FormValidation_checkIndexOutOfBounds;
        this.checkFutureDate = FormValidation_checkFutureDate;
        this.checkCheckBox = FormValidation_checkCheckBox;
        this.checkEmail = FormValidation_checkEmail;
		this.checkTextForInvalidCharacter = FormValidation_checkTextForInvalidCharacter;
    }
    
    /*
     * FormValidation_checkTextForInvalidCharacter() will check the value
     * of a text form element to ensure that the text does not contain the specified
     * invalid character.
     */
    function FormValidation_checkTextForInvalidCharacter(obj, name, invalidChar) {
        var text = Trim(obj.value);
        obj.value = text;

        if (isEmpty(text)) {
            return true;
        } else {
        	if(text.indexOf(invalidChar) > -1) {
        		errorLog.log(name + " cannot contain the " + invalidChar + " character.", obj);
        		return false;
	    	}
		} 

		return true;
        
    }
    

    /*
     * FormValidation_checkText() will check the value
     * of a text form element to ensure data has been 
     * entered.
     */
    function FormValidation_checkText(obj, name, canBeEmpty, canContainQuotes) {
        var text = Trim(obj.value);

        if (canBeEmpty == null) {
            canBeEmpty = false;
        }
        if (canContainQuotes == null) {
            canContainQuotes = false;
        }
        obj.value = text;
        if (isEmpty(text)) {
            if (!canBeEmpty) {
                errorLog.log(name + " cannot be empty.", obj);
            }
        } else {
        	if (containsQuote(text)) {
	    		if (!canContainQuotes) {
				errorLog.log(name + " cannot contain the double quote character.", obj);
	    		}
		} else {
	    		return true;
		}
	}

        return false;
    }

    /*
     * FormValidation_checkInteger() will check the value
     * of a text form element to ensure data has been 
     * entered if it can't be empty, if it can lead with a
     * zero, if it is greater than or equal to the minimum 
     * length, and if it is less than or equal to the maximum 
     * length.
     */
    function FormValidation_checkInteger(obj, name, canBeEmpty, canLeadWithZero, 
                                         minLength, maxLength) {
        var text = Trim(obj.value);

        if (canBeEmpty == null) {
            canBeEmpty = false;
        }
        if (canLeadWithZero == null) {
            canLeadWithZero = false;
        }
        // check the minLength argument
        if (minLength == null) {
            minLength = 1;
        } else if (!isInteger(minLength.toString())) {
            minLength = 1;
        }
        // check the maxLength argument
        if (maxLength == null) {
            maxLength = "unlimited";
        } else if (!isInteger(maxLength.toString())) {
            maxLength = "unlimited";
        }
        if (!isInteger(text)) {
            obj.value = text;
        } else {
            if (!canLeadWithZero) {
                obj.value = parseInt(text);
            }
        }
        if (isEmpty(text)) {
            if (!canBeEmpty) {
                errorLog.log(name + " cannot be empty.", obj);
            } else {
                return true;
            }
        } else if (!isInteger(text)) {
            errorLog.log(name + " must be numeric.", obj);
        } else if (text.length < minLength) {
            errorLog.log(name + " must be at least " + minLength + " digits.", obj);
        } else if (isInteger(maxLength.toString())) {
            if (text.length > maxLength) {
                errorLog.log(name + " must be at no more than " + maxLength + " digits.", obj);
            } else {
                return true;
            }
        } else {
            return true;
        }
        return false;
    }

    /*
     * FormValidation_checkDouble() will check the value
     * of a text form element to ensure data has been 
     * entered as a double.
     */
    function FormValidation_checkDouble(obj, name, precision, canBeEmpty, canBeZero) {
        var text = Trim(obj.value);
        
        if (precision == 0) {
            return this.checkInteger(obj, name, canBeEmpty);
        }
        if (!isEmpty(text)) {
            if (parseInt(text) != 0) {
                text = FormatNumber(text, precision);
            } else {
                text = "0.00";
            }
        }
        if (canBeEmpty == null) {
            canBeEmpty = false;
        }
        if (canBeZero == null) {
            canBeZero = false;
        }
        obj.value = text;
        if (isEmpty(text)) {
            if (!canBeEmpty) {
                errorLog.log(name + " cannot be empty.", obj);
            }
        } else if (!isDouble(text)) {
            errorLog.log(name + " must be valid.", obj);
        } else if (parseInt(text) == 0 && !canBeZero) {
            errorLog.log(name + " cannot be zero.", obj);
        } else {
            return true;
        }
        return false;
    }

    /*
     * FormValidation_checkTextArea() will check the value
     * of a textarea form element to ensure data has been 
     * entered and is not over the maximum length allowed.
     */
    function FormValidation_checkTextArea(obj, name, maxLength, canBeEmpty) {
        var text = Trim(obj.value);

        if (maxLength.toString().toLowerCase() == "unlimited") {
            maxLength = -1;
        }
        if (canBeEmpty == null) {
            canBeEmpty = false;
        }
        obj.value = text;
  
        if (isEmpty(text)) {
            if (!canBeEmpty) {
                errorLog.log(name + " cannot be empty.", obj);
            }
        } else if (text.length > maxLength && maxLength > 0) {
            errorLog.log(name + " is too long; MAX: " + maxLength
                         + " - OVER BY: " + (text.length - maxLength)
                         + " characters", obj);
        } else {
            return true;
        }
        return false;
    }

    /*
     * FormValidation_checkRadio() will check the value
     * of the radio elements array to ensure that at least 
     * one of the radio buttons was checked. if length undefined
     * we have only one and therefore it's not an array
     */
    function FormValidation_checkRadio(obj, name) {
        var checked = false;
        if(obj.length == undefined) {
        	if(obj.checked) { 
        		return true;
        	}
        }
        for (var i = 0; i < obj.length; i++) {
            if (obj[i].checked) {
                checked = true;
                break;
            }
        }
        if (!checked) {
            errorLog.log("Please choose one of the " + name + "s.", obj[0]);
        }
        return checked;
    }
    
    /*
     * FormValidation_checkRadioValue() will check the value
     * of the radio elements array to see if the value on input
     * [a radio button value] was checked. If length undefined
     * we have only one and therefore it's not an array
     */
    function FormValidation_checkRadioValue(obj, value) {
        var checked = false;
        if(obj.length == undefined) {
        	if(obj.checked) { 
        		return true;
        	}
        }
        for (var i = 0; i < obj.length; i++) {
            if (obj[i].value == value && obj[i].checked) {
                checked = true;
                break;
            }
        }
        return checked;
    }
    
    /*
     * FormValidation_checkSelect() will check the selected index
     * of a select form element to ensure the index selected is not
     * the first one if hasSelectableFirst is false.
     */
    function FormValidation_checkSelect(obj, name, hasSelectableIndex0) {
        if (hasSelectableIndex0 == null) {
            hasSelectableIndex0 = false;
        }
        if (!hasSelectableIndex0 && obj.selectedIndex == 0) {
            errorLog.log("Select a valid " + name + ".", obj);
        }
        return false;
    }
    
    /*
     * FormValidation_checkMultiSelect() will check the selected index
     * of a select form element to ensure an index selected is selected
     */
    function FormValidation_checkMultiSelect(obj, name) {
        if (obj.selectedIndex == -1) {
            errorLog.log("Select a valid " + name + ".", obj);
        }
        return false;
    }

    /*
     * FormValidation_checkCheckBox() will ensure that the given check box 
     * is checked.
     */
	function FormValidation_checkCheckBox(obj, name) {
		if(obj.checked == false)
		{
			errorLog.log("Please check " + name + ".", obj);
			return false;
		}
		return true;
	}
	
    /*
     * FormValidation_checkSSN() will check the value
     * of three sperate text elements in a form to 
     * ensure that a vaild SSN was entered.
     */
    function FormValidation_checkSSN(objHidden, objFirst, objMiddle, objLast, name, canBeEmpty) {
        var firstSSN = Trim(objFirst.value);
        var middleSSN = Trim(objMiddle.value);
        var lastSSN = Trim(objLast.value);

        objFirst.value = firstSSN;
        objMiddle.value = middleSSN;
        objLast.value = lastSSN;
        if (canBeEmpty == null) {
            canBeEmpty = false;
        }
        if (isEmpty(firstSSN + middleSSN + lastSSN)) {
            if (!canBeEmpty) {
                errorLog.log(name + " cannot be empty.", objFirst);
            }
        } else if (isEmpty(firstSSN)) {
            errorLog.log(name + " cannot be empty.", objFirst);
        } else if (firstSSN.length < 3) {
            errorLog.log("First part of " + name + " must be 3 digits.", 
                         objFirst);
        } else if (isEmpty(middleSSN)) {
            errorLog.log(name + " cannot be empty.", objMiddle);
        } else if (middleSSN.length < 2) {
            errorLog.log("Middle part of " + name + " must be 2 digits.", 
                         objMiddle);
        } else if (isEmpty(lastSSN)) {
            errorLog.log(name + " cannot be empty.", objLast);
        } else if (lastSSN.length < 4) {
            errorLog.log("Last part of " + name + " must be 4 digits.", 
                         objLast);
        } else if (!isInteger(firstSSN)) {
            errorLog.log(name + " must be numeric.", objFirst);
        } else if (!isInteger(middleSSN)) {
            errorLog.log(name + " must be numeric.", objMiddle);
        } else if (!isInteger(lastSSN)) {
            errorLog.log(name + " must be numeric.", objLast);
        } else if (firstSSN == "000") {
            errorLog.log(name + " start with \"000\".", objFirst);
        } else {
            objHidden.value = firstSSN + middleSSN + lastSSN;
            return true;
        }
        return false;
    }

    /*
    * FormValidation_checkZip() will check the value of two
    * sperate text elements in a form to ensure that a vaild 
    * zip code was entered.
    */
    function FormValidation_checkZip(objHidden, objZip, objPlus4,
                                     name, canBeEmpty, canBeEmptyPlus4) {
        var zip = Trim(objZip.value);
        var plus4 = Trim(objPlus4.value);

        if (canBeEmpty == null) {
            canBeEmpty = false;
        }
        if (canBeEmptyPlus4 == null) {
            canBeEmptyPlus4 = false;
        }
        if (isEmpty(zip + plus4)) {
            if (!canBeEmpty) {
                errorLog.log(name + " cannot be empty.", objZip);
            } else {
                objHidden = zip + plus4;
                return true;
            }
        } else if (isEmpty(zip)) {
            errorLog.log(name + " cannot be empty.", objZip);
        } else if (!isInteger(zip)) {
            errorLog.log(name + " must be numeric.", objZip);
        } else if (zip.length < 5 || zip.length > 5) {
            errorLog.log(name + " must be 5 digits.", objZip);
        } else if (isEmpty(plus4)) {
            if (!canBeEmptyPlus4) {
                errorLog.log(name + " +4 cannot be empty.", objPlus4);
            } else {
                objHidden = zip + plus4;
                return true;
            }
        } else if (!isInteger(plus4)) {
            errorLog.log(name + " +4 must be numeric.", objPlus4);
        } else if (plus4.length < 4 || plus4.length > 4) {
            errorLog.log(name + " +4 must be 4 digits.", objPlus4);
        } else {
            objHidden = zip + plus4;
            return true;
        }
        return false;
    }
    
    /*
    * FormValidation_checkPhoneNumber() will check the value
    * of three separate text elements (or four with extension)
    * in a form to ensure that a valid phone number was entered.
    */
    function FormValidation_checkPhoneNumber(objHidden, objArea, objPrefix, objSuffix, objExt,
                                             name, canBeEmptyPhoneNumber, canBeEmptyExt, canBeEmptyArea) {
        var area = Trim(objArea.value);
        var prefix = Trim(objPrefix.value);
        var suffix = Trim(objSuffix.value);
        var ext = null;
                
        if (objExt != null) {
            ext = Trim(objExt.value);
            objExt.value = ext;
        }
        objArea.value = area;
        objPrefix.value = prefix;
        objSuffix.value = suffix;
        if (canBeEmptyPhoneNumber == null) {
            canBeEmptyPhoneNumber = false;
        }
        if (canBeEmptyExt == null) {
            canBeEmptyExt = true;
        }
	if (canBeEmptyArea == null) {
            canBeEmptyArea = true;
        }
        if (!isEmpty(area + prefix + suffix)) {
            if (isEmpty(area) && !canBeEmptyArea) {
                errorLog.log(name + " area code cannot be empty.", objArea);
            } else if (!isInteger(area) && !isEmpty(area)) {
                errorLog.log(name + " area code must be numeric.", objArea);
            } else if (parseInt(area).toString().length < 3 && !canBeEmptyArea) {
                objArea.value = parseInt(area);
                errorLog.log(name + " area code must be 3 digits.", objArea);
            } else if (isEmpty(prefix)) {
                errorLog.log(name + " prefix cannot be empty.", objPrefix);
            } else if (!isInteger(prefix)) {
                errorLog.log(name + " prefix must be numeric.", objPrefix);
            } else if (prefix.length < 3) {
                errorLog.log(name + " prefix must be 3 digits.", objPrefix);
            } else if (isEmpty(suffix)) {
                errorLog.log(name + " suffix cannot be empty.", objSuffix);
            } else if (!isInteger(suffix)) {
                errorLog.log(name + " suffix must be numeric.", objSuffix);
            } else if (suffix.length < 4) {
                errorLog.log(name + " suffix must be 4 digits.", objSuffix);
            } else if (ext != null) {
                if (isEmpty(ext) && canBeEmptyExt) {
                    objHidden.value = area + prefix + suffix;
                    return true;
                } else {
                    if (!isInteger(ext)) {
                        errorLog.log(name + " extension must be numeric.", objExt);
                    }
                }
            } else {
                objHidden.value = area + prefix + suffix;
                return true;
            }
        } else {
            if (ext != null) {
                if (!isEmpty(ext)) {
                    if (!isInteger(ext)) {
                        errorLog.log(name + " extension must be numeric.", objExt);
                    } else {
                        errorLog.log(name + " cannot be empty if it has an extension.", objArea);
                    }
                } else if (!canBeEmptyExt) {
                    errorLog.log(name + " cannot be empty.", objExt);
                } else {
                    objHidden.value = area + prefix + suffix;
                    return true;
                }
            } else if (canBeEmptyPhoneNumber) {
                objHidden.value = area + prefix + suffix;
                return true;
            } else {
                errorLog.log(name + " cannot be empty.", objArea);
            }
        }
        return false;
    }
	
    /*
     * FormValidation_checkYear() will check the value
     * of a text form element to ensure the year value 
     * entered was valid.
     */
    function FormValidation_checkYear(obj, name) {
        var year = Trim(obj.value);

        obj.value = year;
        if (isEmpty(year)) {
            errorLog.log(name + " cannot be empty.", obj);
        } else if (!isInteger(year)) {
            errorLog.log(name + " must be numeric.", obj);
        } else if (parseInt(year) == 0) {
            errorLog.log(" cannot be zero.", obj);
        } else if (year.length < 4 || year.length > 4) {
            errorLog.log(name + " must be 4 digits.", obj);
        } else if (parseInt(year.charAt(0) + year.charAt(1)) < 19) {
            errorLog.log(name + " is invalid.", obj);
        } else {
            return true;
        }
        return false;
    }
        
    /*
     * FormValidation_checkBirthDate() checks if the date value is
     * passed a valid date; alerting the appropriate message
     * if it is not a valid date.  if the date passes the date check,
     * then the date will be checked to see if it is a valid birth date.
     */
    function FormValidation_checkBirthDate(obj, name, canBeEmpty) {
        if (FormValidation_checkDate(obj, name, canBeEmpty)) {
            var birthDate = new Date(obj.value);
            var date = new Date();
            var dateMinus16Years = new Date();
            var birthDateYear = 
                parseInt(birthDate.toString().substring(birthDate.toString().length - 4, 
                                                        birthDate.toString().length));
            var dateYear = 
                parseInt(date.toString().substring(date.toString().length - 4, 
                                                   date.toString().length));
            
            dateMinus16Years.setYear(dateMinus16Years.getYear() - 16);
            if (birthDate > dateMinus16Years) {
                errorLog.log(name + ' cannot be less than 16 years ago.', obj);
            } else if (dateYear - birthDateYear > 110) {
                errorLog.log(name + ' cannot be more than 110 years ago.', obj);
            } else {
                return true;
            }
        }
        return false;
    }

    /*
     * FormValidation_checkPastDueDate() checks if the date value is
     * passed a valid date; alerting the appropriate message
     * if it is not a valid date.  if the date passes the date check,
     * then the date will be checked to see if it is a valid past due date.
     */
    function FormValidation_checkPastDueDate(obj, name, canBeEmpty) {
        if (FormValidation_checkDate(obj, name, canBeEmpty)) {
            var pastDueDate = new Date(obj.value);
            var date = new Date();
            var dateMinus7Years = new Date();
            
            dateMinus7Years.setYear(dateMinus7Years.getYear() - 7);
            if (pastDueDate > date) { 
                errorLog.log(name + ' cannot be greater than today.', obj);
            } else if (pastDueDate < dateMinus7Years) {
                errorLog.log(name + ' cannot be more than 7 years ago.', obj);
            } else {
                return true;
            }
        }
        return false;
    }
    
    function FormValidation_checkDateLessThan(obj1, obj2, name, earlierThanDesc) {
        var date1 = obj1.value;
        var convertedDate1 = date1.substring(6) + "-" + date1.substring(0,2) + "-" + date1.substring(3,5);
        
        var date2 = obj2.value;
        var convertedDate2 = date2.substring(6) + "-" + date2.substring(0,2) + "-" + date2.substring(3,5);
        
        if(convertedDate1 > convertedDate2) {
            errorLog.log("Your " + name + " (" + date1 + ") cannot be earlier than the " + earlierThanDesc + " (" + date2 + ")", obj2 );
        } else {
           return true;
        }
        return false;
            
    }
    
    /*
     * FormValidation_checkFutureDate() checks to make sure that
     * the date is in the correct format and that the value is the 
     * current day or a future day.  The format should be MMDDYYYY
     * or its delimited version.  
     */
    function FormValidation_checkFutureDate(obj, name, canBeEmpty) {
		if(FormValidation_checkDate(obj, name, canBeEmpty))
		{
		    var today = new Date();
			today.setHours(0, 0, 0, 0);
			var date = obj.value;

			if(Date.parse(date) >= Date.parse(today))
				return true;
			else
			{
				errorLog.log(name + ' can not be earlier than today');
				return false;
			}
		}
	}
	
    function FormValidation_checkIndexOutOfBounds(objToCheck, objWithIndex, objToCheckName, objWithIndexName) {
        var valToCheck = objToCheck.value;
        var indexToUse = objWithIndex.value;
        
        if(indexToUse != "" && valToCheck.length < indexToUse) {
            errorLog.log("The " + objWithIndexName + " index is larger than the length of " + objToCheckName, objWithIndex);
        } else {
           return true;
        }
        return false;
            
    }
    
    /*
     * FormValidation_checkEmail() checks to make sure that
     * the field is an actual Email address
     */
    function FormValidation_checkEmail(obj, name, canBeEmpty) {
		var valToCheck = obj.value;
		
		if (canBeEmpty == null) {
            canBeEmpty = false;
        }
        
        if(!canBeEmpty) {
        	if(isEmail(valToCheck))
				return true;
			else {
				errorLog.log(name + ' is incorrectly formatted');
				return false;
			}
		} else {
			return true;
		}
	}

    /*
     * FormValidation_checkDate() checks if the date value is
     * passed a valid date; alerting the appropriate message
     * if it is not a valid date.
     */
    function FormValidation_checkDate(obj, name, canBeEmpty) {
        if (canBeEmpty == null) {
            canBeEmpty = false;
        }
        // date value of the object passed
        var date = Trim(obj.value);
        // date parsed into month, day, & year variables 
        // using the '/' as a delimiter      
        var month = '', day = '', year = '';
        // date delimiter counter variable
        var delimiterCtr = 0;
        // boolean variable set whether date,
        // without slashes is numeric
        var integer = true;
        var delimiter = '/';
        var	format = "MM/DD/YYYY or MM-DD-YYYY";
    
        // add the slashes if they do not exist in the date
        if (!isEmpty(date)) {
            if (isInteger(date)) {
                if (date.length == 8) {
                    date = date.charAt(0) + date.charAt(1) + "/" 
                           + date.charAt(2) + date.charAt(3) + "/" 
                           + date.charAt(4) + date.charAt(5)
                           + date.charAt(6) + date.charAt(7);
                } else if (date.length == 6) {
                    date = date.charAt(0) + date.charAt(1) + "/" 
                           + date.charAt(2) + date.charAt(3) + "/" 
                           + date.charAt(4) + date.charAt(5);
                }
            }
        }
        // allow the date field to be empty if canBeEmpty == true
        if (isEmpty(date) && canBeEmpty) {
            return true;
        } else if (isEmpty(date)) {
            errorLog.log(name + ' required - Format: ' + format, obj);
        } 
        // END checking empty date
        else if (date.length <= 5) {
            errorLog.log('Invalid value for ' + name + ' - Format: ' + format, obj);
        } 
        // END checking for invalid date length
        else {
            if (date.indexOf('-') != -1) {
                delimiter = '-';
            }
            for (var i = 0; i < date.length; i++) {
                if (date.charAt(i) != delimiter) {
                    number = false;
                    if (!isInteger(date.charAt(i))) {
                        integer = false;
                        break;
                    } 
                    // END if..then; break out of for loop if 
                    // date isn't numeric
                    if (delimiterCtr == 0) {
                        month += date.charAt(i);
                    }
                    else if (delimiterCtr == 1) {
                        day += date.charAt(i);
                    }
                    else {
                        year += date.charAt(i);
                    }
                } 
                // END if..then checking for '\' or '-' in date
                else {
                    delimiterCtr++;
                } 
                // END if..then; increment delimiterCtr if a '/' or '-' is found
            } 
            // END for loop
            if (isInteger(year) && year.length == 2) {
                if (parseInt(year) >= 30) {
                    year = "19" + year;
                } else {
                    year = "20" + year;
                }
            }
            if (day.length == 1) {
                day = "0" + day.toString()
            }
            // append a zero to day if day length is 1
            if (month.length == 1) {
                month = "0" + month.toString()
            }
            // append a zero to month if month length is 1
            if (!integer) {
                errorLog.log('No Characters Allowed in ' + name + ' - Format: ' + format, obj);
            } 
            // END if; alert if date is not numeric
            else if (isEmpty(day) || isEmpty(year)) {
                errorLog.log('Invalid value for ' + name + ' - Format: ' + format, obj);
            } 
            // END else if; alert if day or year is empty
            else if (year.length != 4) {
                errorLog.log(name + ' needs a 4 digit year - Format: ' + format, obj);
            } 
            // END else if; alert if year is not 4 digits in length
            else { 
                if (month < 1 || month > 12 || day < 1) {
                    errorLog.log('Invalid value for ' + name + ' - Format: ' + format, obj);
                } 
                // END if; alert if month is less than 1 or 
                // greater than 12 or the day is less than 1
                else if ((month == 1 || month == 3 || month == 5 ||
                    month == 7 || month == 8 || month == 10 || month == 12) && day > 31) {
                        errorLog.log(name + ' only has 31 Days in Month - Format: ' + format, obj);
                } 
                // END else if; alert if the day is greater than 31 days 
                else if ((month == 4 || month == 6 || month == 9 ||
                    month == 11) && day > 31) {
                        errorLog.log(name + ' only has 30 Days in Month - Format: ' + format, obj);
                } 
                // END else if; alert if the day is greater than 30 days 
                else if ((month == 2) && day > 29) {
                    if (isLeapYear(year)) {
                        errorLog.log(name + ' only has 29 Days in Month - Format: ' + format, obj);
                    } 
                    // END if; alert if the day is greater than 29 days 
                    // when a leap year
                else {
                    errorLog.log(name + ' only has 28 Days in Month - Format: ' + format, obj);
                } 
                // END if..then; alert if the day is greater than 28 days 
                // when not a leap year
            } 
            // END if..then checking for whether or not year is a leap year
            else if ((month == 2) && day > 28 && !isLeapYear(year)) {
                if (day == 29) {
                    errorLog.log(name + ' is not a Leap Year - Format: ' + format, obj);
                } 
                // END if; alert if the day equals 29 and 
                // the year is not a leap year 
                } 
                // END else if checking whether day entered is 29 
                else {
                    obj.value = month + "/" + day + "/" + year
                    return true;
                } 
                // END if..then; return true if date validation is OK
            } 
            // END if..then
        } 
        // END if..then validating the date 
        return false;
        // return false if date validation is not OK
    } 
    // END checkDate() function
//-->

