var bIsCancelled = false;

function Form_Validator(theForm)
{
  var bIsValid = true;

  if (!bIsCancelled)
  {
	var objFormValidator;

	objFormValidator = new FormValidator();

	objFormValidator.addValidation(
			IsPresent(theForm.name.value),
			"Name must be entered",
			theForm.name
	);
				
	objFormValidator.addValidation(
        LengthBetween(theForm.name.value, 0, 255),
		"Name (max length 255 characters)",
		theForm.name
	);
	
	objFormValidator.addValidation(
			IsPresent(theForm.address1.value),
			"Address must be entered",
			theForm.address1
	);
				
	objFormValidator.addValidation(
        LengthBetween(theForm.address1.value, 0, 255),
		"Address (max length 255 characters)",
		theForm.address1
	);
	
	objFormValidator.addValidation(
        LengthBetween(theForm.address2.value, 0, 255),
		"Address (max length 255 characters)",
		theForm.address2
	);
	
	objFormValidator.addValidation(
        LengthBetween(theForm.address3.value, 0, 255),
		"Address (max length 255 characters)",
		theForm.address3
	);
	
	objFormValidator.addValidation(
        LengthBetween(theForm.address4.value, 0, 255),
		"Address (max length 255 characters)",
		theForm.address4
	);
	
	objFormValidator.addValidation(
			IsPresent(theForm.town.value),
			"Town must be entered",
			theForm.town
	);
				
	objFormValidator.addValidation(
        LengthBetween(theForm.town.value, 0, 255),
		"Twon (max length 255 characters)",
		theForm.town
	);
	
	objFormValidator.addValidation(
			IsPresent(theForm.county.value),
			"County must be entered",
			theForm.county
	);
				
	objFormValidator.addValidation(
        LengthBetween(theForm.county.value, 0, 255),
		"County (max length 255 characters)",
		theForm.county
	);
	
	objFormValidator.addValidation(
			IsPresent(theForm.postcode.value),
			"Post code must be entered",
			theForm.postcode
	);
				
	objFormValidator.addValidation(
        LengthBetween(theForm.postcode.value, 0, 10),
		"Postcode (max length 255 characters)",
		theForm.postcode
	);
	
	objFormValidator.addValidation(
        LengthBetween(theForm.telephone.value, 0, 255),
		"Telephone (max length 255 characters)",
		theForm.telephone
	);
	
	objFormValidator.addValidation(
        LengthBetween(theForm.mobile.value, 0, 255),
		"Mobile (max length 255 characters)",
		theForm.mobile
	);
	
	objFormValidator.addValidation(
        LengthBetween(theForm.email.value, 0, 255),
		"Email (max length 255 characters)",
		theForm.email
	);
	
	objFormValidator.addValidation(
        LengthBetween(theForm.notes.value, 0, 4000),
		"Notes (max length 4000 characters)",
		theForm.notes
	);
	
	
	bIsValid = objFormValidator.validate();
  }

  return bIsValid;
}
