// JavaScript Document
function validate(){
	
	var strCountry = document.getElementById("country").value;
	var strName = document.getElementById("name").value;
	var strPhone = document.getElementById("phone").value;
	var strHouse = document.getElementById("house").value;
	var strPostcode = document.getElementById("postcode").value;
	var strEmail = document.getElementById("email").value;
	var strLoanamount = document.getElementById("loanamount").value;
	var strLoantype = document.getElementById("loantype").value;
	
// declaring and initializing variables
	
	var strErrorArray=[];
	var strErrorMsg="Please correct the following";
	strErrorMsg+="\n---------------------------------------------------\n---------------------------------------------------\n";
	
// checking values

	if(strCountry==""){
		strErrorArray.push("Please select Country");
	}
	if(strName==""){
		strErrorArray.push("Please fill in Name");
	}
	if(strPhone==""){
		strErrorArray.push("Please fill in Phone Number");
	}else if(isNaN(strPhone)){
		strErrorArray.push("Please fill in valid Phone Number");
	}
	if(strHouse==""){
		strErrorArray.push("Please fill in House No./Name");
	}
	if(strPostcode==""){
		strErrorArray.push("Please fill in Postcode");
	}
	if(strLoanamount==""){
		strErrorArray.push("Please fill in Loan Amount");
	}else if(isNaN(strLoanamount)){
		strErrorArray.push("Please fill in valid Loan Amount");
	}
	if(strLoantype==""){
		strErrorArray.push("Please select Loantype");
	}
	
// on error(s) dispalying them
	
	if(strErrorArray.length==0){
		return true;
	}else{
		for(var i=0;i<strErrorArray.length;i++){
			strErrorMsg+=(i+1)+". "+strErrorArray[i]+"\n";
		}
		alert(strErrorMsg);
		return false;
	}
	
}

function isValidEmailAddress(email){
 	var regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	return regex.test(email);
 }

