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

  reason += validateEmpty(theForm.name,"Personal details: Username");
  reason += validateEmpty(theForm.email,"Personal details: Email");
  reason += validateEmpty(theForm.phone,"Personal details: Phone");
  reason += validateEmpty(theForm.movefrom,"Move from: Size");
  reason += validateEmpty(theForm.address1,"Move from: Address");
  reason += validateEmpty(theForm.town,"Move from: Town-city");
  reason += validateEmpty(theForm.county,"Move from: County");
  reason += validateEmpty(theForm.postcode,"Move from: Postcode");
  reason += validateEmpty(theForm.floor,"Move from: Floor");
  reason += validateEmpty(theForm.lift,"Move from: Lift");
  reason += validateEmpty(theForm.moveto,"Move to: Size");
  reason += validateEmpty(theForm.newaddress1,"Move to: Address");
  reason += validateEmpty(theForm.newtown,"Move to: Town-city");
  reason += validateEmpty(theForm.newcounty,"Move to: County");
  reason += validateEmpty(theForm.newpostcode,"Move to: Postcode");
  reason += validateEmpty(theForm.newfloor,"Move to: Floor");
  reason += validateEmpty(theForm.newlift,"Move to: Lift");
  reason += validateEmpty(theForm.date,"Dates: Date");
  reason += validateEmpty(theForm.time,"Dates: Time");
  reason += validateEmpty(theForm.hear,"How did you hear about us?");


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

  return true;
}

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