<!-- Author:      Jason McReynolds // -->
<!-- Email:       jason@typeslowly.co.uk // -->
<!-- Studio:      Typeslowly // -->
<!-- Location:    London, Uk // -->
<!-- Web:         www.typeslowly.co.uk // -->

<!-- Description:  // -->
<!-- The script is developed to validate form input data // -->


<!-- Script Starts Here That Validates User Input
function checkform(thisform)
{
	<!--  // -->
	if(thisform.usrCNAME.value == null || thisform.usrCNAME.value == "")
	{
		alert("Please include the childs full name");
		thisform.usrCNAME.focus();
		thisform.usrCNAME.select();
		thisform.usrCNAME.style.backgroundColor = "#e8e2ec";
		return false;
	}
	
	<!--  // -->
	if(thisform.usrAGE.value == null || thisform.usrAGE.value == "")
	{
		alert("Please include the childs age");
		thisform.usrAGE.focus();
		thisform.usrAGE.select();
		thisform.usrAGE.style.backgroundColor = "#e8e2ec";
		return false;
	}
	
	<!--  // -->
	if(thisform.usrSCHOOL.value == null || thisform.usrSCHOOL.value == "")
	{
		alert("Please include the childs school");
		thisform.usrSCHOOL.focus();
		thisform.usrSCHOOL.select();
		thisform.usrSCHOOL.style.backgroundColor = "#e8e2ec";
		return false;
	}
	
	<!--  // -->
	if(thisform.usrYEARGROUP.value == null || thisform.usrYEARGROUP.value == "")
	{
		alert("Please include the childs school year group");
		thisform.usrYEARGROUP.focus();
		thisform.usrYEARGROUP.select();
		thisform.usrYEARGROUP.style.backgroundColor = "#e8e2ec";
		return false;
	}
	
	<!--  // -->
	if(thisform.usrPARENT.value == null || thisform.usrPARENT.value == "")
	{
		alert("Please include the name of the childs parent");
		thisform.usrPARENT.focus();
		thisform.usrPARENT.select();
		thisform.usrPARENT.style.backgroundColor = "#e8e2ec";
		return false;
	}
	
	<!--  // -->
	if(thisform.usrADDRESS.value == null || thisform.usrADDRESS.value == "")
	{
		alert("Please include your address");
		thisform.usrADDRESS.focus();
		thisform.usrADDRESS.select();
		thisform.usrADDRESS.style.backgroundColor = "#e8e2ec";
		return false;
	}
	
	<!--  // -->
	if(thisform.usrPOSTCODE.value == null || thisform.usrPOSTCODE.value == "")
	{
		alert("Please include your post code");
		thisform.usrPOSTCODE.focus();
		thisform.usrPOSTCODE.select();
		thisform.usrPOSTCODE.style.backgroundColor = "#e8e2ec";
		return false;
	}
	<!--  // -->
	if(thisform.usrMOBILE.value == null || thisform.usrMOBILE.value == "")
	{
		alert("Please include a contact mobile number");
		thisform.usrMOBILE.focus();
		thisform.usrMOBILE.select();
		thisform.usrMOBILE.style.backgroundColor = "#e8e2ec";
		return false;
	}
	
	
	<!-- Check User Has Inputted a usrEmail // -->
	if(thisform.usrEmail.value == null || thisform.usrEmail.value == "")
	{
		alert("Please enter a valid email address");
		thisform.usrEmail.focus();
		thisform.usrEmail.select();
		thisform.usrEmail.style.backgroundColor = "#e8e2ec";
		return false;
	}
	
	<!-- Check the user has input a valid email address. 1. Check for Bad Characters //-->
	invalidChars = " /:,;=(){}[]*$";
	for (i=0; i<invalidChars.length;i++)
	{
		badChar = invalidChars.charAt(i)
		if (thisform.usrEmail.value.indexOf(badChar,0) > -1)
		{
			alert("Please enter a valid email address");
			thisform.usrEmail.focus();
			thisform.usrEmail.select();
			thisform.usrEmail.style.backgroundColor = "#e8e2ec";
			return false
		}
	}
	<!-- Check the user has input a valid email address. 2. Check for @ within the email address //-->
	atPos = thisform.usrEmail.value.indexOf("@",1)
	if (atPos == -1)
	{
		alert("Please enter a valid email address");
		thisform.usrEmail.focus();
		thisform.usrEmail.select();
		thisform.usrEmail.style.backgroundColor = "#e8e2ec";
		return false
	}
	<!-- Check the user has input a valid email address. 3. Check for only one @ within the email address //-->
	if (thisform.usrEmail.value.indexOf("@",atPos+1) > -1)
	{
		alert("Please enter a valid email address");
		thisform.usrEmail.focus();
		thisform.usrEmail.select();
		thisform.usrEmail.style.backgroundColor = "#e8e2ec";
		return false
	}
	<!-- Check the user has input a valid email address. 4. Check that a . appears after the @ within the email address //-->
	periodPos = thisform.usrEmail.value.indexOf(".",atPos)
	if (periodPos == -1)
	{
		alert("Please enter a valid email address");
		thisform.usrEmail.focus();
		thisform.usrEmail.select();
		thisform.usrEmail.style.backgroundColor = "#e8e2ec";
		return false
	}
	<!-- Check the user has input a valid email address. 5. Check that at least two characters appear after the . //-->
	if (periodPos+3>thisform.usrEmail.value.length)
	{
		alert("Please enter a valid email address");
		thisform.usrEmail.focus();
		thisform.usrEmail.select();
		thisform.usrEmail.style.backgroundColor = "#e8e2ec";
		return false
	}
	
	<!--  // -->
	if(thisform.usrTERMS.checked == false)
	{
		alert("You must agree to the terms and conditions");
		thisform.usrTERMS.focus();
		thisform.usrTERMS.style.border = "#e8e2ec";
		return false;
	}
	
return true;
}
// Script Ends-->
