function CheckForm() {

	//Intialise variables
	var errorMsg = "";
	var errorMsgLong = "";
	var invalid = " "; // Invalid character is a space

	//Check for spaces
	if (document.feedback.name.value.indexOf(invalid) > -1) {errorMsg += "\n\tName \t\t- Sorry, spaces are not allowed";
	}
	if (document.feedback.address.value.indexOf(invalid) > -1) {errorMsg += "\n\tAddress \t\t- Sorry, spaces are not allowed";
	}
	if (document.feedback.email.value.indexOf(invalid) > -1) {errorMsg += "\n\tE-mail \t\t- Sorry, spaces are not allowed";
	}
	if (document.feedback.message.value.indexOf(invalid) > -1) {errorMsg += "\n\tMessage \t\t- Sorry, spaces are not allowed";
	}
	
	//Check for a name
	if (document.feedback.name.value == ""){
		errorMsg += "\n\tName \t\t- Enter your Name";
	}
	
	//Check for address
	if (document.feedback.address.value == ""){
		errorMsg += "\n\tAddress \t\t- Enter your Address";
	}
	
	//Check for a country
	if (document.feedback.country.value == "0"){
		errorMsg += "\n\tCountry \t\t- Select the country you are in";
	}
	
	//Check for email
	if (document.feedback.email.value == ""){
		errorMsg += "\n\tEmail \t\t- Enter your E-mail address";
	}
	
	//Check for message
	if (document.feedback.message.value == ""){
		errorMsg += "\n\tMessage \t- Enter a Message to add to the Guestbook";
	}
	
	//Check the word length before submitting
	words = document.feedback.message.value.split(' ');
	for (var loop = 0; loop <= words.length - 1; ++loop){
		if (words[loop].length >= 50){
		errorMsgLong += "\n- A word in your comments contains " + words[loop].length + " characters, this needs to be shortened to below 50 characters.";
		}	
	}	
		
	//Check for HTML tags before submitting the form	
	for (var count = 0; count <= 7; ++count){
		if ((document.feedback.elements[count].value.indexOf("<", 0) >= 0) && (document.feedback.elements[count].value.indexOf(">", 0) >= 0)){
			errorMsgLong += "\n- HTML tags are not permitted, remove all HTML tags.";
		}			
	}
	
	//If there is a problem with the form then display an error
	if ((errorMsg != "") || (errorMsgLong != "")){
		msg = "___________________________________________________________________\n\n";
		msg += "Your Comments have not been added because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "___________________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: -\n";
		
		errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong);
		return false;
	}
	
	return true;
}
