// <form onsubmit="return validateFormOnSubmit(this)" action="submit.php">

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

  reason += validateEmpty(theForm.email);
  reason += validateEmpty(theForm.name);
  reason += validateEmpty(theForm.phone);
  reason += validateEmpty(theForm.message);

  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }

  return true;
}

function validateEmpty(field) {
    var error = "";
 
    if (field.value.length == 0) {
        field.style.background = 'Yellow'; 
        error = field.name+" has not been filled in.\n"
    } else {
        field.style.background = 'White';
    }
    return error;  
}

function validateCheckBox(theForm,field) {
    var error = "";	
	 if (	document.forms[theForm].elements[field].checked = false )
		{
			error = "You must check the "+field+" box.\n"
		}
    return error;  
}