function validateFormOnSubmit(theForm) {
var reason = "";
  
  reason += validateEmpty(theForm.billingname);  
  reason += validatePhone(theForm.phonenumber); 
  reason += validatePassword(theForm.password); 
  reason += validateAnswer(theForm.answertoquestion); 
  
  
          
  if (reason != "") {
    alert("Please fill in the following fields:\n" + reason);
    return false;
  }

  //alert("All fields are filled correctly");
  return true;
}
function validateEmpty(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "Please enter a Name.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}


function validatePhone(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "Please enter a Phone.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}

function validatePassword(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "Please enter a Password.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}


function validateAnswer(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "Please enter a Answer.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}
