<!--
function checkForm(myForm) {
    var redColor = '#ffb0b0';

    for (var i=0; i < myForm.elements.length; i++ ) {
        if (myForm[i].type == 'hidden') {
            continue;
        }

        if (typeof(myForm[i].alt) == 'undefined') {
            fieldName = myForm[i].name;
        } else {
            fieldName = myForm[i].alt;
        }

        if (myForm[i].className == 'required' && myForm[i].value == '') {
            alert("The " + fieldName + " field is required. It appears that you have not set it.");
            myForm[i].style.backgroundColor = redColor;
            myForm[i].focus();
            return false;
        } else if ( myForm[i].value == '' ) {
            continue;
        }

        if ( myForm[i].name.search(/dob/i) != -1 ) {
            if(myForm[i].value == 'YYYY-MM-DD') {
                continue;
            }
            var dateVar = myForm[i].value.split("-");
            if ( !dateVar[2] ) {
                alert("The " + fieldName + " field should be of the form YYYY-MM-DD. Please make sure there are dashes between your year, month, and day.");
                myForm[i].style.backgroundColor = redColor;
                myForm[i].focus();
                return false;
            }

            var year = dateVar[0];
            var month = dateVar[1] - 1; // Javascript uses months from 0-11
            var day = dateVar[2];

            if ( year < 1850 ) {
                alert("The " + fieldName + " field should be of the form YYYY-MM-DD. We have detected a small year in your date. This could be because there are two digits in your year or the order of the year, the month, and the day are mixed up.");
                myForm[i].style.backgroundColor = redColor;
                myForm[i].focus();
                return false;
            }

            var dateObject = new Date(year,month,day);

            if ( (year != dateObject.getFullYear()) || (month != dateObject.getMonth()) || (day != dateObject.getDate()) ) {
                alert("The " + fieldName + " field should be of the form YYYY-MM-DD. The date given to us does not seem to be valid.");
                myForm[i].style.backgroundColor = redColor;
                myForm[i].focus();
                return false;
            }

            continue;
        } else if ( myForm[i].name.search(/password/i) != -1 ) {
            if ( myForm[i].value.length == 0 ) {
                continue;
            } else if ( myForm[i].value.length < 6 ) {
                alert("The " + fieldName + " field must have at least 6 characters.");
                myForm[i].style.backgroundColor = redColor;
                myForm[i].focus();
                return false;
            /*} else if ( myForm[i].value.toLowerCase() == myForm[i].value ) {
                alert("A password must have at least one uppercase letter and cannot be all numbers. Please edit the " + fieldName + " field.");
                myForm[i].style.backgroundColor = redColor;
                myForm[i].focus();
                return false;
            } else if ( myForm[i].value.toUpperCase() == myForm[i].value ) {
                alert( "A password must have at least one lowercase letter and cannot be all numbers. Please edit the " + fieldName + " field.");
                myForm[i].style.backgroundColor = redColor;
                myForm[i].focus();
                return false;
            */} else if ( myForm[i].value.search(/[\x00 \n \r ' " \x1a ; `]/i) != -1 ) {
                alert( "Your password has some characters which cannot be used. Both single and double quotes and also semicolons and backticks are not allowed. Please edit the " + fieldName + " field.");
                myForm[i].style.backgroundColor = redColor;
                myForm[i].focus();
                return false;
            /*} else if ( myForm[i].value.search(/[^A-Za-z]/) == -1) {
                alert("A password cannot be only letters. It must have at least one character that is not A-Z or a-z. Please edit the " + fieldName + " field.");
                myForm[i].style.backgroundColor = redColor;
                myForm[i].focus();
            */    return false;
            } else if ( typeof(myForm.password2) != "undefined" ){
                if (myForm.password2.value != myForm[i].value) {
                    alert("Your passwords do not match.");
                    myForm[i].style.backgroundColor = redColor;
                    myForm[i].focus();
                    return false;
                }
            } else {
                continue;
            }
        } else if ( myForm[i].name.search(/email/i) != -1 ) {
            if ( myForm[i].value.length == 0 ) {
                continue;
            } else if ( myForm[i].value.search(/^[\w\.\-\+]+@[\w\.\-]+\.[\w\.\-]{1,6}$/) == -1) {
                alert("The " + fieldName + " field should have a valid email address in the form of someone@example.com. It cannot have any characters except A-Z, a-z, 0-9, dot, dash, underscore and @.");
                myForm[i].style.backgroundColor = redColor;
                myForm[i].focus();
                return false;
            } else {
                continue;
            }
        } else { // it's a text field, like varchar
            continue;
        }
    }

    return true;
}
//-->