
function validate(){
 var errors = [];
 var form=document.getElementById("theForm");
 
  var userName = form.Name.value;
 var phone = form.Phone.value;
 var email = form.Email.value;

 if (userName.length === 0) {
  alert("You must enter a Name.");
  return false;
 }

 if (phone.length === 0) {
  alert("You must enter a Phone.");
  return false;
 }
 
  if (email.length === 0) {
  alert("You must enter a Email.");
  return false;
 }

if (validate1(form)==false)
 {
 return false;
 }
 
 if (validatechild(form)==false)
 {
 return false;
 }
 
 
 
 if (validateroom(form)==false)
 {
 return false;
 }

  if (validatecid(form)==false)
 {
 return false;
 }
 
   if (validatepl(form)==false)
 {
 return false;
 }
 

 if (validate2(form)==false)
 {
 return false;
 }
 
 return true;
}

function checkCheckBox(cb){
 return cb.checked;
}

function reportErrors(errors){
 var msg = "Please select...\n";
 var numError;
 for (var i = 0; i<errors.length; i++) {
  numError = i + 1;
  msg += "\n" + numError + ". " + errors[i];
 }
 alert(msg);
}





function validate2(form){
 var errors = [];
if ( !checkCheckBox(form.Terms) ) {
  errors[errors.length] = "You must agree to the Terms.";
 }
 
 if (errors.length > 0) {
  reportErrors(errors);
  return false;
 }
}






function validate1(form){
 var errors = [];
 
 if ( !checkSelect(form.Adult) ) {
  errors[errors.length] = "You must choose Adult.";
 }
 
 if (errors.length > 0) {
  reportErrors(errors);
  return false;
 }
 
 return true;
}

function checkSelect(select){
 return (select.selectedIndex > 0);
}

function reportErrors(errors){
 var msg = "";
 var numError;
 for (var i = 0; i<errors.length; i++) {
  numError = i + 1;
  msg += "\n" + numError + ". " + errors[i];
 }
 alert(msg);
}





function validatechild(form){
 var errors = [];
 
 if ( !checkSelect(form.Child) ) {
  errors[errors.length] = "You must choose Child.";
 }
 
 if (errors.length > 0) {
  reportErrors(errors);
  return false;
 }
 
 return true;
}

function checkSelect(select){
 return (select.selectedIndex > 0);
}

function reportErrors(errors){
 var msg = "";
 var numError;
 for (var i = 0; i<errors.length; i++) {
  numError = i + 1;
  msg += "\n" + numError + ". " + errors[i];
 }
 alert(msg);
}












function validateroom(form){
 var errors = [];
 
 if ( !checkSelect(form.Rooms) ) {
  errors[errors.length] = "You must choose a Room.";
 }
 
 if (errors.length > 0) {
  reportErrors(errors);
  return false;
 }
 
 return true;
}

function checkSelect(select){
 return (select.selectedIndex > 0);
}

function reportErrors(errors){
 var msg = "";
 var numError;
 for (var i = 0; i<errors.length; i++) {
  numError = i + 1;
  msg += "\n" + numError + ". " + errors[i];
 }
 alert(msg);
}




function validatecid(form){
 var errors = [];

  var cid = form.CheckIn.value;
 var cod = form.CheckOut.value;
 if (cid.length === 0) {
  alert("You must enter a Check In Date.");
  return false;
 }

 if (cod.length === 0) {
  alert("You must enter a Check Out Date.");
  return false;
 }
  return true;
  }












function validatepl(form){
 var errors = [];
 
 if ( !checkSelect(form.Plan) ) {
  errors[errors.length] = "You must choose a plan.";
 }
 
 if (errors.length > 0) {
  reportErrors(errors);
  return false;
 }
 
 return true;
}

function checkSelect(select){
 return (select.selectedIndex > 0);
}

function reportErrors(errors){
 var msg = "";
 var numError;
 for (var i = 0; i<errors.length; i++) {
  numError = i + 1;
  msg += "\n" + numError + ". " + errors[i];
 }
 alert(msg);
}



