//Basic Form Field Verification Script
//-------------------------------------
//-------------------------------------
//Author: Alex Robinson
//Date: 23rd January 2009
//Version 1.1
//Date Modified: 20th February 2009
//Revisions: Deleted some scripts to match simplified form
//-------------------------------------
//-------------------------------------

//Regular Expressions to be checked and modified as needed - use these for required fields
//FirstName /^([A-Za-z]+)$/
//LastName /^([A-Za-z]+)$/
//email /^([0-9a-zA-Z]+)([0-9a-zA-Z\.-_]+)@([0-9a-zA-Z\.-_]+)\.([0-9a-zA-Z]+)/
//Phone /^([0-9]{5})-| ([0-9]{6})/

//The FirstName 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_FirstName = /^([A-Za-z]+)$/;

//assigns the entered FirstName to a variable

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

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

var format_match1= required_FirstName.test(FirstName.value);


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


if (format_match1)

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

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

//The LastName Check Script

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

function match2(){

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

var required_LastName = /^([A-Za-z]+)$/;

//assigns the entered LastName to a variable

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

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

var format_match2= required_LastName.test(LastName.value);


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


if (format_match2)

{
	
}
	
	else
{	window.alert ("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 match3(){

//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_match3= required_email.test(email.value);


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


if (format_match3)

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


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


//The phone number Check Script

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

function match4(){

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

var required_DayTel = /^([0-9]{5})-| ([0-9]{6})/;

//assigns the entered phone number to a variable

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

//tests whether the entered phone number matches the required phone number format

var format_match4= required_DayTel.test(DayTel.value);


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


if (format_match4)

{
	
}
	
	else
{	window.alert ("Invalid number format - Please check and re-enter e.g. in the format '01234 567890'.");
	
}
	
}


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


//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_FirstName = /^([A-Za-z]+)$/;

//assigns the entered FirstName to a variable

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

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

var format_match1= required_FirstName.test(FirstName.value);


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

var required_LastName = /^([A-Za-z]+)$/;

//assigns the entered LastName to a variable

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

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

var format_match2= required_LastName.test(LastName.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_match3= required_email.test(email.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;
		
}
			
	
		


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


//Regular Expressions - ASP - from TT282


