$('#submit').click(function()
{    
  if($('#number').val()=='' && $('#code').val()== '')
  {
alert('Please Enter House Number And postcode');
  }
  else
  {
  //Get Postcode
  var number = $('#number').val();
  var postcode = $('#code').val();
  
  //Get latitude & longitude
  $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address=' + postcode + '&sensor=false',  
            function(data) {
              var lat = data.results[0].geometry.location.lat;
              var lng = data.results[0].geometry.location.lng;
              
  //Get address    
  $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?latlng=' + lat + ',' + lng + '&sensor=false',  
            function(data) {     
			
              var address = data.results[0].address_components;   
              var street = address[1].long_name;
              var town = address[2].long_name;
              var county = address[3].long_name;    
			  var test = address[4].long_name;
			   var code = address[5].long_name;
			    var code1 = address[6].long_name;
			  $('#city').val(address[3].long_name);
			  $('#postcode').val(postcode);
			   $('#countryname').val(address[6].long_name);
			   $('#address').val(number + ', ' + street + ', ' + town + ', ' + county + ', ' + postcode+','+code+','+code1);
			   document.getElementById('country').style.display='none';
			   document.getElementById('countryname').style.display='block';
			  
  //Insert
  //$('#address').value(text(number + ', ' + street + ', ' + town + ', ' + county + ', ' + postcode));
     
    });
  });
}});