function checkfields(y5form) {
    errors = "";

    if (y5form.firstname.value == "") {
      errors += "  * missing First Name\n";
    } else if (!fnamevalid(y5form.firstname.value)) {
      errors += "  * invalid First Name\n";
    }
    if (y5form.lastname.value == "") {
      errors += "  * missing Last Name\n";
    } else if (!lnamevalid(y5form.lastname.value)) {
      errors += "  * invalid Last Name\n";
    }
    if (y5form.email.value == "") {
      errors += "  * missing E-mail\n";
    } else if (!emailvalid(y5form.email.value)) {
      errors += "  * invalid E-mail\n";
    }
    if (y5form.phone.value == "") {
      errors += "  * missing Phone\n";
    } else if (!phonevalid(y5form.phone.value)) {
      errors += "  * invalid Phone\n";
    }

if (errors == "") {
      return true;
    } else {
      alert("Your request could not be processed because of the following errors:\n" + errors);
      return false;
    }
}
function fnamevalid(firstname) {
    checkfname = /^[a-zA-Z]{1,}$/;
    return(checkfname.exec(firstname));
}
function lnamevalid(lastname) {
    checklname = /^[a-zA-Z]{1,}$/;
    return(checklname.exec(lastname));
}
function emailvalid(email) {
    checkemail = /^[\da-zA-Z]{2,}[\.\-]?[\da-zA-Z]{0,}\@[\da-zA-Z]{2,}[\.\-]?[\da-zA-Z]{0,}\.[a-zA-Z]{2,3}$/;
    return(checkemail.exec(email));
}
function phonevalid(phone) {
    checkphone = /^\(?\d{3}\)?\s?[\-\.]?\s?\d{3}\s?[\-\.]?\s?\d{4}$/;
    return(checkphone.exec(phone));
}

