function validation()
{

	//**************************************************************************************
	//Validation For First Name(Check for Blank Name)
	if(document.frm.First_name.value=="")
	{
		alert("Please enter the  name");
		
		document.frm.First_name.focus();
		return false;
	}
	//(Check for Blank Space)
	if(document.frm.First_name.value.indexOf(" ")==0)
	{
		alert("There should not be any space before the name")
		
		document.frm.First_name.focus();
		return false;
	}
	//(Check for Charectors only Name)
	var chk = Ischar(document.frm.First_name.value)
	if(chk == false)
	{
		alert("Please use characters only");
		document.frm.First_name.focus();
		return false;
	}
	//end of validation
		if((document.frm.H_telephone.value==""))
	{
		alert("Please enter any one phone number");
		document.frm.H_telephone.focus();
		return false;
	}
	else
	{
		if(!(document.frm.H_telephone.value==""))
	
		{
			//Validation for Home Telephone
			if(document.frm.H_telephone.value=="")
			{
				alert("Please enter the home telephone no.")
				document.frm.H_telephone.focus();
				return false;
			}
	
			//(check for valid telephone no.)
			if ((!(document.frm.H_telephone.value.length==10)) && (!(document.frm.H_telephone.value.length==11))) 
    		{
       			alert("Length of home telephone no. should  be upto 10-11 digit");
	   			document.frm.H_telephone.focus();
	   			return false;
    		} 
	
			//(check for Numeric value only)
			var chk = IsNumeric(document.frm.H_telephone.value)
			if(chk == false)
			{
				alert("Home telephone no. should be in numeric");
				document.frm.H_telephone.focus();
				return false;
			} 
			if((document.frm.H_telephone.value.indexOf("0")==0 ) && (document.frm.H_telephone.value.indexOf("7")==1))
      		{
	    		alert("Please enter valid home telephone no.");
				document.frm.H_telephone.focus();
	    		return false;
       		}
		}
	}
	//****************************************************************************

		if(!(document.frm.email.value == ""))
    {//(check for '@' symbol)
		if(document.frm.email.value.indexOf("@") == -1)
    	{
     		alert("Please enter valid email");
			
      		document.frm.email.focus();
      		return false;
   		}
    	//(check '.' symbol)
    	if(document.frm.email.value.indexOf(".") == -1)
    	{
			alert("Please enter valid email");
			
			document.frm.email.focus();
			return false;
   		 }
	}
	//end of validation
	if(document.frm.debtdetails.value=="")
	{
		alert("Please enter the project Details");
		
		document.frm.debtdetails.focus();
		return false;
	}
	//validation for Loan Amount(check first 0)
	if(document.frm.Loan_amt.value == "")
	{
		alert("Loan amount field cannot be blank");
		document.frm.Loan_amt.focus();
		return false;
	}
	if(document.frm.Loan_amt.value.indexOf("0") == 0)
	{
		alert("Amount cannot be zero");
		document.frm.Loan_amt.focus();
		return false;
	}
	//Validation for Loan Amount
	var chk = IsNumeric(document.frm.Loan_amt.value)
	if(chk == false)
	{
		alert("Please enter the loan amount as a number, with no decimal points and no characters like ‘£‘, ‘,’ etc.");
		document.frm.Loan_amt.focus();
		return false;
	}
	//end validation loan Amt
	return true;
}
//check for valid numerical strings
function IsNumeric(strString)
{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   //  test strString consists of valid characters listed above
   for (j = 0; j < strString.length && blnResult == true; j++)
   {
     strChar = strString.charAt(j);
     if (strValidChars.indexOf(strChar) == -1)
     {
        blnResult = false;
     }
   }
   return blnResult;
}	
	
//check for valid charector strings
function Ischar(strString)
{
  var strValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
  var strChar;
  var blnResult = true;

  if (strString.length == 0) return false;
 //  test strString consists of valid characters listed above
  for (j = 0; j < strString.length && blnResult == true; j++)
  {
     strChar = strString.charAt(j);
     if (strValidChars.indexOf(strChar) == -1)
     {
        blnResult = false;
     }
  }
  return blnResult;
}
//function for postcode
function postit(strString)
{//check postcode format is valid
 	test = strString; 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.details.pcode.value = test; //write back to form field
 	if (size < 6 || size > 8)
	{ //Code length rule
    		return false;
  	}
 	if (!(isNaN(test.charAt(0))))
	{ //leftmost character must be alpha character rule
      		return false;
  	}
 	if(isNaN(test.charAt(size-3)))
	{ //first character of inward code must be numeric rule
     		return false;
  	}
 	if (!(isNaN(test.charAt(size-2))))
	{ //second character of inward code must be alpha rule
     		return false;
  	}
 	if (!(isNaN(test.charAt(size-1))))
	{ //third character of inward code must be alpha rule
      		return false;
  	}
 	//if(!(test.charAt(size-4) == " "))
	//{//space in position length-3 rule
     // 		return false;
   //	}
 	//count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 	//if (count1 != count2)
	//{//only one space rule
    // 		return false;
  	//}
	return true;
}

function dateCheck(m, d, y) 
{
	if(m != '')
	{//alert(m)
		if(m == "Apr" || m == "Jun" || m == "Sep" || m == "Nov")
		{//alert("hello")
			if(d == "31")
			{ 
				return false; 
			} 
		} 
		if(m == "Feb")
		{ 
			if(parseInt(y)%4 != 0 && d == "29")
			{	 
				return false; 
			} 
			else if(d == 30 || d== 31)
			{ 
				return false; 
			} 
		} 
	return true; 
	} 
} 
