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 validateForm(){
	
 var strArrayError = [];
 var strErrorMsg="";
 var strErrorColour="#DDDDDD";
 var strNormalColour="#FFFFFF";

// receiving values

 var strFirstName = document.getElementById("firstname").value;
 var strLastName = document.getElementById("lastname").value;
 var strLoanAmount = document.getElementById("loanamount").value;
 var strLoanType = document.getElementById("loantype").value;
 
// checking for values

 if(strFirstName==""){
 	strArrayError.push("Please enter your First Name");	
	document.getElementById("firstname").style.background=strErrorColour;
 }else{
 	document.getElementById("firstname").style.background=strNormalColour;
 }
 
 if(strLastName==""){
 	strArrayError.push("Please enter your Last Name");	
 	document.getElementById("lastname").style.background=strErrorColour;
 }else{
 	document.getElementById("lastname").style.background=strNormalColour;
 }
 
if(strLoanAmount==""){
 	strArrayError.push("Please enter your Loan Amount");	
 	document.getElementById("loanamount").style.background=strErrorColour;
 }else if(!isNumber(strLoanAmount)){
      strArrayError.push("Please enter valid Loan Amount");	
 	document.getElementById("loanamount").style.background=strErrorColour;	 
 }else{
 	document.getElementById("loanamount").style.background=strNormalColour;
 }
 
if(strLoanType==""){
 	strArrayError.push("Please Select your Loan Type");	
 	document.getElementById("loantype").style.background=strErrorColour;
 }else{
 	document.getElementById("loantype").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;
 }
}