function isNumber(number){
	if(isNaN(number)){
		return false;
	}else{
		return true;
	}
}
function isValidEmail(email){
	var regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	return regex.test(email);
}
function validate(){
	
 var strArrayError = [];
 var strErrorMsg="";
 var strErrorColour="#DDDDDD";
 var strNormalColour="#FFFFFF";

// receiving values

 var strAmountRequired = document.getElementById("amountrequired").value;
 var strTitle = document.getElementById("title").value;
 var strForename = document.getElementById("forename").value;
 var strSurname = document.getElementById("surname").value;
 var strDob = document.getElementById("dob").value;
 var strDayTimePhone = document.getElementById("daytimephone").value;
 var strEmail = document.getElementById("email").value;
 var strMobile = document.getElementById("mobile").value;
 var strFirstLineofAddress = document.getElementById("firstlineofaddress").value;
 var strPostcode = document.getElementById("postcode").value;
 var strTimeatAddress = document.getElementById("timeataddress").value;
 var strMonthlyIncome = document.getElementById("monthlyincome").value;
 var strYearsWithEmployer = document.getElementById("yearswithemployer").value;
 
// checking for values

 if(strAmountRequired==""){
 	strArrayError.push("Please enter your Required Amount");	
	document.getElementById("amountrequired").style.background=strErrorColour;
 }else{
 	document.getElementById("amountrequired").style.background=strNormalColour;
 }
 
 if(strTitle==""){
 	strArrayError.push("Please enter your Title");	
 	document.getElementById("title").style.background=strErrorColour;
 }else{
 	document.getElementById("title").style.background=strNormalColour;
 }
 
 if(strForename==""){
 	strArrayError.push("Please enter your Forename");	
 	document.getElementById("forename").style.background=strErrorColour;
 }else{
 	document.getElementById("forename").style.background=strNormalColour;
 }
 
 if(strSurname==""){
 	strArrayError.push("Please enter your Surname");	
 	document.getElementById("surname").style.background=strErrorColour;
 }else{
 	document.getElementById("surname").style.background=strNormalColour;
 }
 
 if(strDob==""){
 	strArrayError.push("Please enter your Date of Birth");	
 	document.getElementById("dob").style.background=strErrorColour;
 }else{
 	document.getElementById("dob").style.background=strNormalColour;
 }
 
  if(strDayTimePhone==""){
 	strArrayError.push("Please enter your Day Time Phone");	
 	document.getElementById("daytimephone").style.background=strErrorColour;
 }else{
 	document.getElementById("daytimephone").style.background=strNormalColour;
 }
 
 
 if(strEmail==""){
 	strArrayError.push("Please enter your Email Address");
	document.getElementById("email").style.background=strErrorColour;
 }else if(!isValidEmail(strEmail)){
 	strArrayError.push("Please enter valid Email Address");	
 	document.getElementById("email").style.background=strErrorColour;
 }else{
 	document.getElementById("email").style.background=strNormalColour;
 }
 
 if(strMobile==""){
 	strArrayError.push("Please enter your Mobile Number");	
 	document.getElementById("mobile").style.background=strErrorColour;
 }else{
 	document.getElementById("mobile").style.background=strNormalColour;
 }
 
 if(strFirstLineofAddress==""){
 	strArrayError.push("Please enter your First Line of Address");	
 	document.getElementById("firstlineofaddress").style.background=strErrorColour;
 }else{
 	document.getElementById("firstlineofaddress").style.background=strNormalColour;
 }
 
 if(strPostcode==""){
 	strArrayError.push("Please enter your Postcode");	
 	document.getElementById("postcode").style.background=strErrorColour;
 }else{
 	document.getElementById("postcode").style.background=strNormalColour;
 }
 
 
 if(strTimeatAddress==""){
 	strArrayError.push("Please enter your Time at Address");	
 	document.getElementById("timeataddress").style.background=strErrorColour;
 }else{
 	document.getElementById("timeataddress").style.background=strNormalColour;
 }
 
  if(strMonthlyIncome==""){
 	strArrayError.push("Please enter your Monthly Income");	
 	document.getElementById("monthlyincome").style.background=strErrorColour;
 }else{
 	document.getElementById("monthlyincome").style.background=strNormalColour;
 }
 
  if(strYearsWithEmployer==""){
 	strArrayError.push("Please enter Your Years with Employer");	
 	document.getElementById("yearswithemployer").style.background=strErrorColour;
 }else{
 	document.getElementById("yearswithemployer").style.background=strNormalColour;
 }
 
// checking for errors and displaying them
 if(strArrayError.length==0){
  return true;
 }else{ 
  strErrorMsg+="Your application form was not submitted because of following error(s).\n";
  strErrorMsg+="----------------------------------------------------------------------------\n";
  strErrorMsg+="----------------------------------------------------------------------------\n";
 
  for(var i=0; i<strArrayError.length; i++){
 	strErrorMsg+=strArrayError[i]+"\n";
  }
  alert(strErrorMsg);
  return false;
 }
}