//  Gconnect Javascript Include File
//
//  Gconnect - The Business ISP - www.gconnect.net


//
// checkit function
//
// There are several built in validation routines included, you must include the validation
// needed in the form element name.
//
//	address1 - Alphanumerics, - & spaces , min=2 max=15 
//	postcode - 2 groups of 2-4 letters and numbers separated by a optional space
//	email - any number of legal name characters followed by an @, then 3 legal letters, optional .XX and then .2 or 3 letters 
//	telephone - numbers and spaces only min=10 max=16
//	alphanum - letters, numbers, dashes and spaces only, no character limit.
//
// Enjoy!

function checkitless(){
	var namestr = "";
	var a;
	a = document.forms[0].elements.length;
		
	for(var counter=0;counter<a;counter++){
		namestr = document.forms[0].elements[counter].name;

		//email
		if(namestr.match(/email/)){
			if(! document.forms[0].elements[counter].value.match(/^[a-zA-Z0-9\-_\.]*\@[a-zA-Z0-9\-]{3,}(\.)?([a-zA-Z]{2})?\.[a-zA-Z]{2,4}$/)){
				alert("Please fill in an appropriate Email value");
				document.forms[0].elements[counter].focus();
				return false;

			}
		}

	
	}
	return true;
}



function checkit(){
	var namestr = "";
	var a;
	a = document.forms[0].elements.length;
		
	for(var counter=0;counter<a;counter++){
		namestr = document.forms[0].elements[counter].name;

		//name
		if(namestr.match(/Name/) || namestr.match(/name/)){
			if(! document.forms[0].elements[counter].value.match(/^[a-zA-Z0-9 \-]{2,20}$/)){
				alert("Please fill in an appropriate Name field value");
				document.forms[0].elements[counter].focus();
				return false;
			}
		}
		
		//address
		if(namestr.match(/Address/) || namestr.match(/address/)){
			if(! document.forms[0].elements[counter].value.match(/^[a-zA-Z0-9 \-]{2,40}$/)){
				alert("Please fill in an appropriate Address field value");
				document.forms[0].elements[counter].focus();
				return false;
			}
		}


		//town
		if(namestr.match(/[Tt]own/)){
			if(! document.forms[0].elements[counter].value.match(/^[a-zA-Z0-9 \-]{2,40}$/)){
				alert("Please fill in an appropriate Town field value");
				document.forms[0].elements[counter].focus();
				return false;
			}
		}



		//county
		if(namestr.match(/[Cc]ounty/)){
			if(! document.forms[0].elements[counter].value.match(/^[a-zA-Z0-9 \-]{2,40}$/)){
				alert("Please fill in an appropriate County/Area field value");
				document.forms[0].elements[counter].focus();
				return false;
			}
		}


		//postcode
		if(namestr.match(/Postcode/) || namestr.match(/postcode/)){
			if(! document.forms[0].elements[counter].value.match(/^[a-zA-Z0-9]{2,4} *[a-zA-Z0-9]{2,4}$/)){
				alert("Please fill in an appropriate Post Code value");
				document.forms[0].elements[counter].focus();
				return false;
			}
		}
	
		//email
		if(namestr.match(/email/)){
			if(! document.forms[0].elements[counter].value.match(/^[a-zA-Z0-9\-_\.]*\@[a-zA-Z0-9\-]{3,}(\.)?([a-zA-Z]{2})?\.[a-zA-Z]{2,4}$/)){
				alert("Please fill in an appropriate Email value");
				document.forms[0].elements[counter].focus();
				return false;

			}
		}
		
		//telephone
		if(namestr.match(/Telephone/) || namestr.match(/telephone/)){
			if(! document.forms[0].elements[counter].value.match(/^[0-9 +\-]{10,16}$/)){
				alert("Please fill in an appropriate Telephone Number value");
				document.forms[0].elements[counter].focus();
				return false;
			}
		}
		
		//alphanum
		if(namestr.match(/alphanum/)){
			if(! document.forms[0].elements[counter].value.match(/^[a-zA-Z0-9 \-\.,]*$/)){
				alert("Please fill in an appropriate Text value");
				document.forms[0].elements[counter].focus();
				return false;
			}
		}


	
	}
	return true;
}


