 function validateForm(contactform)
 {
 	//oForm refers to the form which you want to validate
 	contactform.onsubmit = function() // attach the function to onsubmit event
 	{
 		var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
 		if(contactform.elements['name'].value.length<1)
 		{
 			alert("Please Enter Your Name");
 			return false;
 		}
 		else if(contactform.elements['phone'].value.length<1)
 		{
 			alert("Please Enter Your Phone Number");
 			return false;
 		}

 		else if(contactform.elements['email'].value.length<1)
 		{
 			alert("You cannot leave the email field empty");
 			return false;
 		}
 		
 		else if(!regex.test(contactform.elements['email'].value))
 		{
 			alert("Invalid email address format");
 			return false;
 		}
 		else if(contactform.elements['address'].value.length<1)
 		{
 			alert("Please Enter Your Address");
 			return false;
 		}
 		else if(contactform.elements['messagebox'].value.length<1)
 		{
 			alert("Please Enter Your Message into the Message box");
 			return false;
 		}
 		return true;
 	}
 }

