// JavaScript Document

function fnCheck()
{
	if(name.value.length<2) // checking that this is not blank & is more than 2 characters in length
		{
			alert("Please enter your full name.");
			name.focus();
			return false;
		}
		
	if(email.value.indexOf("@")==-1 || email.value.indexOf(".")==-1 || email.value==("")) /*checking if the email has an @ sign, a . and has no spaces or is blank */
		{
			alert("Please enter your best contact email address.");
			email.select();
			return false;
		}
		
	if(ph.value.length<8) //checking if phone # is no less than 8 digits in length 
		{
			alert("Please enter a contact number.");
			ph.focus();
			return false;
		}
	
	if(make.value.length<2) // checking that this is not blank & is more than 2 characters in length
		{
			alert("Please enter your vehicles Make.");
			make.focus();
			return false;
		}
	
	if(model.value.length<2) // checking that this is not blank & is more than 2 characters in length
		{
			alert("Please enter your vehicles Model type.");
			model.focus();
			return false;
		}
		
	if(kms.value.length<2) // checking that this is not blank & is more than 2 digits in length
		{
			alert("Please enter your vehicles current Kilometres / ODO reading.");
			kms.focus();
			return false;
		}
	
	if(msg.value.length<5) // checking that this is not blank & is more than 2 characters in length
		{
			alert("Please enter your request.");
			msg.focus();
			return false;
		}
		
	return true;
}





var formX = document.getElementById("form_contact");
var name = document.getElementById("txtName");
var email = document.getElementById("txtEmail");
var ph = document.getElementById("txtPh");
var make = document.getElementById("txtMake");
var model = document.getElementById("txtModel");
var kms = document.getElementById("txtKms");
var msg = document.getElementById("txtMsg");




document.getElementById("txtName").focus();



formX.onsubmit = fnCheck;