//Basic Form Field Verification Script
//-------------------------------------
//-------------------------------------
//Author: Alex Robinson
//Date: 10th August 2009
//Version 1.1

//-------------------------------------
//-------------------------------------

//Field id's to match are 'name', 'email', 'question'

//Regular Expressions to be checked and modified as needed - use these for required fields
//Name /^([a-zA-Z\s]+)$/
//email /^([0-9a-zA-Z]+)([0-9a-zA-Z\.-_]+)@([0-9a-zA-Z\.-_]+)\.([0-9a-zA-Z]+)/
//Question /^([0-9a-zA-Z\s\.\?,]+)$/

//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------


//The Name Check Script

//This function checks the validity of the name format and alerts if incorrect

function match1(){

//sets up a variable with a regular expression which defines the required name format

var required_Name = /^([a-zA-Z\s]+)$/;

//assigns the entered Name to a variable

var Name = document.getElementById('name');

//tests whether the entered name matches the required name format

var format_match1= required_Name.test(Name.value);


//if else statement defines action if match or no match


if (format_match1)

{
	
}
	
	else
{	window.alert ("Name - Invalid Entry. Please re-enter using alphabetic characters only.");
	
}
	
}

//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------


//The email Check Script

//This function checks the validity of the email format and alerts if incorrect

function match2(){

//sets up a variable with a regular expression which defines the required email format

var required_email = /^([0-9a-zA-Z]+)([0-9a-zA-Z\.-_]+)@([0-9a-zA-Z\.-_]+)\.([0-9a-zA-Z]+)/;

//assigns the entered email to a variable

var email = document.getElementById('email');

//tests whether the entered email matches the required email format

var format_match2= required_email.test(email.value);


//if else statement defines action if match or no match


if (format_match2)

{
	
}
	
	else
{	window.alert ("Email address - Invalid email address - Please check and re-enter e.g. in the format 'joe@abc.net'.");
	
}
	
}


//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------



//The Question Check Script

//This function checks the validity of the Question format and alerts if incorrect

function match3(){

//sets up a variable with a regular expression which defines the required Question format

var required_Question = /^([0-9a-zA-Z\s\.\?,]+)$/;

//assigns the entered Question to a variable

var Question = document.getElementById('question');

//tests whether the entered question matches the required format

var format_match3= required_Question.test(Question.value);


//if else statement defines action if match or no match


if (format_match3)

{
	
}
	
	else
{	window.alert ("Question - Invalid format. Please check and re-enter using letters, numbers and .,? punctuation only.");
	
}
	
}

//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------



//The Submit Check Script
//To check that any required form fields are completed and valid prior to submission

function submitcheck()

{

//sets up a variable with a regular expression which defines the required name format

var required_Name = /^([a-zA-Z\s]+)$/;

//assigns the entered Name to a variable

var Name = document.getElementById('name');

//tests whether the entered name matches the required name format

var format_match1= required_Name.test(Name.value);




//sets up a variable with a regular expression which defines the required email format

var required_email = /^([0-9a-zA-Z]+)([0-9a-zA-Z\.-_]+)@([0-9a-zA-Z\.-_]+)\.([0-9a-zA-Z]+)/;

//assigns the entered email to a variable

var email = document.getElementById('email');

//tests whether the entered email matches the required email format

var format_match2= required_email.test(email.value);



//sets up a variable with a regular expression which defines the required Question format

var required_Question = /^([0-9a-zA-Z\s\.\?,]+)$/;

//assigns the entered Question to a variable

var Question = document.getElementById('question');

//tests whether the entered question matches the required format

var format_match3= required_Question.test(Question.value);


var complete=true;

//if else statement defines action to be taken according to conditions



if ((format_match1)&&(format_match2)&&(format_match3))
		{	
		window.alert ("Thank You - your enquiry has been submitted.");
		complete=true;
		}
		else
		{window.alert ("Please enter data in the required field or check that the data entered is in the correct format.");
		complete=false;
		}
		
return complete;
		
}
			
	
		


	
		
//-------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------





