

	function CheckSubmitone()
	{		
		
			if (document.mailform.mainapplicantname.value == "")
	  	{
	  		alert("Please enter your first name.")
			return
		}
			if (document.mailform.mainapplicantsurname.value == "")
	  	{
	  		alert("Please enter your surname.")
			return
		}


			if (document.mailform.yearofb.value == "year")
	  	{
	  		alert("Please enter a valid date of birth.")
			return
		}


{ 
 test = document.mailform.postcode.value; size = test.length
 test = test.toUpperCase(); //Change to uppercase
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
 document.mailform.postcode.value = test; //write back to form field
 if (size < 6 || size > 8){ //Code length rule
  alert("please enter a valid postcode");
  document.mailform.postcode.focus();
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   alert(test + " is not a valid postcode - cannot start with a number");
   document.mailform.postcode.focus();
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   alert(test + " is not a valid postcode - alpha character in wrong position");
   document.mailform.postcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   document.mailform.postcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   document.mailform.postcode.focus();
   return false;
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
   alert(test + " is not a valid postcode - no space or space in wrong position");
   document.mailform.postcode.focus();
   return false;
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   alert(test + " is not a valid postcode - only one space allowed");
   document.mailform.postcode.focus();
   return false;
  }
	}
		if((document.mailform.newproperty[0].checked=="") && (document.mailform.newproperty[1].checked==""))
		{
    			alert('Have you found a property?');
			return
		}
	



		if((document.mailform.newproperty[0].checked==true) && (document.mailform.newpostcode.value == ""))
		{
    			alert('Please enter your new postcode, if not known please enter where about in the \r country are you looking to purchase ?    i.e. postcode area or city or county');
			return
		}
		if((document.mailform.newproperty[1].checked==true) && (document.mailform.newpostcode.value == ""))
		{
    			alert('where about in the country are you looking to purchase ? \r i.e. postcode area or city or county');
			return
		}




	document.mailform.submit()

	     }





	function CheckSubmittwo()
	{
		
		if (document.mailform.contactnumber.value == "")
		{	
			alert("Please enter your contact number.")
			return			
		}
		if (document.mailform.emailaddress.value == "")
	  	{
	  		alert("Please enter your emailaddress.\r\n\r\n Enter 'none' if you do not have an email address")
			return
		}
		if (document.mailform.mainapplicantsalary.value == "")
	  	{
	  		alert('Please enter annual salary.\r\n\r\nEnter "0" if you do not have a salary,\r\nor if salary is unknown please enter "unknown"')
			return
		}
   

                if((document.mailform.jointapplication[0].checked=="") && (document.mailform.jointapplication[1].checked==""))
		{
    			alert('Is this a joint application?');
			return
		}

		if((document.mailform.jointapplication[0].checked==true) && (document.mailform.titleapp2.value == ""))
		{
    			alert('Please enter the second applicants title');
			return
		}		if((document.mailform.jointapplication[0].checked==true) && (document.mailform.applicantname2.value == ""))
		{
    			alert('Please enter the second applicants first name');
			return
		}		if((document.mailform.jointapplication[0].checked==true) && (document.mailform.applicantsurname2.value == ""))
		{
    			alert('Please enter the second applicants surname');
			return
		}		
			if ((document.mailform.jointapplication[0].checked==true) && (document.mailform.yearofb2.value == "year"))
	  	{
	  		alert("Please enter a valid date of birth for second applicant.")
			return
		}

		if((document.mailform.jointapplication[0].checked==true) && (document.mailform.partnersalary.value == ""))
		{
    			alert('Please enter second applicants annual salary.\r\n\r\n Enter "0" if applicant does not have a salary,\r\nor if salary is unknown please enter "unknown"');
			return
		}		
		
		if((document.mailform.creditcard[0].checked=="") && (document.mailform.creditcard[1].checked==""))
		{
    			alert('Do you have any outstanding credit cards and/or loans?');
			return
		}

		if((document.mailform.creditcard[0].checked==true) && (document.mailform.creditcardowe.value == ""))
		{
    			alert('Please enter amount owed on credit/store cards or amount owed on other loans or credit');
			return
		}	

		if((document.mailform.badcredit[0].checked=="") && (document.mailform.badcredit[1].checked==""))
		{
    			alert('Do you have any C.C.Js, defaults or arrears?');
			return
		}

		if((document.mailform.badcredit[0].checked==true) && (document.mailform.badcreditdetails.value == ""))
		{
    			alert('Please enter details of any C.C.Js, defaults or arrears');
			return
		}
		if((document.mailform.type[0].checked=="") && (document.mailform.type[1].checked==""))
		{
    			alert('Is this a remortgage enquiry?');
			return
		}

	document.mailform.submit()

	     }



	function CheckSubmitthree()
	{

		if (document.mailformmortgage.mortamountreq.value == "")
		{	
			alert("Please enter the mortgage amount required.");
			return			
		}
		if (document.mailformmortgage.propertyvalue.value == "")
		{
    			alert("Please enter purchase price.\r\n\r\n If not known please enter approx value of intended purchase");
			return
		}
		if (document.mailformmortgage.deposit.value == "- - -")
		{
    			alert("Please enter deposit amount or enter none.");
			return
		}

	document.mailformmortgage.submit()

	     }
		 
		 
		 
		 
	function CheckSubmitthreeb()
	{

		if (document.mailformremortgage.mortamountreq.value == "")
		{	
			alert("Please enter the mortgage amount required.");
			return			
		}

		if (document.mailformremortgage.propertyvalue.value == "")
		{
    			alert("Please enter current property value.");
			return
		}

		if (document.mailformremortgage.outstandingmortgage.value == "")
		{
    			alert("Please enter current outstanding mortgage.");
			return
		}

		if (document.mailformremortgage.purpose.value == "- - -")
		{
    			alert("Please enter purpose of remortgage.");
			return
		}

	document.mailformremortgage.submit()

	     }


	function CheckSubmitfour()


	{   document.mailform.submit()   }
