function validateForm3OnSubmit(theForm) {
var reason = "";

  reason += validateEmpty(theForm.firstname);
  reason += validateEmpty(theForm.lastname);
  reason += validateEmpty(theForm.dob_month);
  reason += validateEmpty(theForm.dob_day);
  reason += validateEmpty(theForm.dob_year);
  reason += validateEmpty(theForm.address);
  reason += validateEmpty(theForm.city);
  reason += validateEmpty(theForm.state);
  reason += validateEmpty(theForm.zip);
  reason += validateEmpty(theForm.phone);
  reason += validateEmail(theForm.email);
  reason += validateEmpty(theForm.design_file);
  
      
  if (reason != "") {
    alert("Some fields need correction:\n" + "You must fill in all fields. Incorrect fields have been highlighted yellow.");
    return false;
  }

  return true;
}
function validateForm2OnSubmit(theForm) {
var reason = "";

  if (theForm.agree.checked == false) {
    alert("You must agree to the terms and conditions by checking the box next to I AGREE above.");
    return false;
  }

  return true;
}
function validateEmpty(fld) {
    var error = "";
  
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        fld.style.color = '#000000';
        error = "Missing fields have been highlighted in yellow.\n"
    } else {
        fld.style.background = '#64b407';
    }
    return error;   
}
function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Yellow';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = '#64b407';
    }
    return error;
}