// JavaScript Document
//create check function

function  fnCheck()
{
	// check valid text longer than 2 characters
	if(Name.value.length<2)
	{
		alert("Please enter your  name");
		Name.focus();
		return false
	}
	// check for valid email
	
	if(mail.value.indexOf("@") ==-1 || mail.value.indexOf(".") ==-1)
	{
		alert("You must enter a valid email");
		mail.focus();
		return false
	}
	
	alert("Thank you we will be in touch shortly");
	return true;

}
	

//define variables

//for form

formX = document.getElementById("contactForm");

//for text input

var Name =document.getElementById("txtName");
var mail = document.getElementById("txtMail");

// focus in first field
Name.focus();

//bring focus of browser to fnCheck before submitting to mail

formX.onsubmit = fnCheck;



