

function RegExpTest(pEmail)
{
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  return regex.test(pEmail);
}


function checkform(){

	//alert ("validate funciton called");
	
	
	
	/* required fields */
	//var base = "document.frmContact";
	varName = document.frmContact.txt_name.value;
	varCompanyName = document.frmContact.txt_company_name.value;
	varEmailAddress = document.frmContact.txt_email_address.value;
	varLocation = document.frmContact.txt_location.value;

	
	
	//start of error message
	errorMsg = "Please correct the following:\n"; 
	error = false; // error flag
	


	//check if Name is empty
	if (varName == "") 		{
		errorMsg = errorMsg + "  - Name is required\n";
		error = true;
	}
	
	//check if Name is empty
	if (varCompanyName == "") 		{
		errorMsg = errorMsg + "  - Company name is required\n";
		error = true;
	}
	
	//check if Name is empty
	/*
	if (varLocation == "") 		{
		errorMsg = errorMsg + "  - Location is required\n";
		error = true;
	}
	*/
		
	//check if email address is empty
	if (varEmailAddress == "") 		{
		errorMsg = errorMsg + "  - Email address is required\n";
		error = true;
	} 
	
	if (varEmailAddress != "") 		{
		//check if email address is valid
		if (!(RegExpTest(varEmailAddress)))			{
			errorMsg = errorMsg + "  - Email address is invalid\n";
			error = true;
		}
	}
	

		
			
	//if any of the above then display error message and don't submit form
	if (error) 		{
		alert(errorMsg)
		return false
	} 
	else 		{
	//it's all good and form can go
	base.action = "../events.asp";
	base.submit();
	


	return true;
	}
}