//Trim
function trimAll(sString) 
	{
		while (sString.substring(0,1) == ' ')
		{
		sString = sString.substring(1, sString.length);
		}
		while (sString.substring(sString.length-1, sString.length) == ' ')
		{
		sString = sString.substring(0,sString.length-1);
		}
	return sString;
	}
	
function validate()
{
  var zip=document.getElementById('txt_zip').value;
    frm=document.home_form;	
	alert_message='';
	focus_field='';
  if (trimAll(frm.txt_zip.value) == "" || trimAll(frm.txt_zip.value) == "Zip") 
	{	
	
	alert_message ='Please Enter Zip.\n';
	
	if(focus_field=="")
	focus_field = "txt_zip";
	}
	else 
	{
	  if(isNaN(frm.txt_zip.value))
	  {
	   
		alert_message = 'Zip should be numeric.\n';
	
		if(focus_field=="")
		focus_field = "txt_zip";
	  
	  }
		else if(!(/^\d+$/.test(frm.txt_zip.value))) 
		{ 
		
			alert_message = ' Your Zip should be Valid\n'; 
			if(focus_field=="")
			focus_field = "txt_zip";		
		}
		else if(frm.txt_zip.value<=0)
		{
				
				alert_message = 'Zip should be Valid\n';
				if(focus_field=="")
				focus_field = "txt_zip";
		}
	  else if(frm.txt_zip.value.length!=5)
	  {
	   
		alert_message ='Zip should be 5 digit.\n';
	
		if(focus_field=="")
		focus_field = "txt_zip";
	  
	  }
	 	
	}
  if(alert_message)
  {
	  alert(alert_message);
      return false;
  }
  else
  { 

  document.getElementById('home_form').submit();
  }
}
