Call the ViewAddress on TextBox change event.
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_Key"></script>
<script type="text/javascript">
function ViewAddress() {
navigator.geolocation.getCurrentPosition(
function (position) {
var LatLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var geocoder = geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'latLng': LatLng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
document.getElementById('txtaddress').value = results[0].formatted_address;
} elese {
document.getElementById('txtaddress').value = "address is not valid";
}
});
}, function (error) {
alert(error.code + ": " + error.message);
}, {
enableHighAccuracy: true,
maximumAge: 10000,
timeout: 5000
});
}
</script>
<input type="text" id="txtaddress" onchange="ViewAddress()" />