Plugin Examples

We have added some examples below to demonstrate different configurations of the Autoaddress jQuery plugin. ​By adding custom logic based on events you can integrate the Autoaddress plugin easily into your environment.


 

Using the onAddressFound(data) Callback, you can use the response data to auto-populate a sample form.

We recommend using the preferred address format by setting vanityMode to true and to pass an addressProfile as a parameter. This will return a reformattedAddressin the response data.

Contact us to get a custom profile made for your form.

<script type="text/javascript">
$(function(){
    $("#myDiv").AutoAddress({
       key : "YOUR_KEY",
vanityMode : true, addressProfile: "Default5Line", onAddressFound: function (data) { if (data.reformattedAddress) { $.each(data.reformattedAddress, function (index, value) { $('#addressLine' + (index + 1)).val(value); }); } if (data.postcode) { $('#postcode').val(data.postcode); } } }); }); </script>
 

If you wish to have a custom address format returned for your form you can pass an addressProfile as a parameter. This will then return a reformattedAddress in the response to your specification.

Contact us to get a custom profile made for your form.

<script type="text/javascript">
$(function(){
   $("#myDiv").AutoAddress({
      key : "YOUR_KEY",
vanityMode : true, addressProfile: "DemoApi5Line", onAddressFound: function (data) { if (data.reformattedAddress) { $.each(data.reformattedAddress, function (index, value) { $('#addressLine' + (index + 1)).val(value); }); } if (data.postcode) { $('#postcode').val(data.postcode); } } });
});
</script>
<script type="text/javascript">
   $.ajax({
      url: "//api.autoaddress.ie/2.0/verifyaddress",
      dataType: 'jsonp',
      jsonp: "callback",
      type: "GET",
      data: {
        key: "YOUR_KEY",
        address: "YOUR_ADDRESS",
        postcode: "YOUR_POSTCODE"
      }
   }).success(function (data) {
      //success code
   });
</script>
 

Using the onAddressFound(data) Callback, you can use the response data to auto-populate a sample form.

The Autoaddress jQuery Plugin can search in English and Irish. To switch the control to search in Irish you just need to configure the language property. This example also shows how you can configure the message labels of the plugin to suit your needs.

<script type="text/javascript">
$(function(){
   $("#myDiv").AutoAddress({
      key : "YOUR_KEY",
      language: "​GA",
      vanityMode : true,
      onAddressFound: function (data) {
      if (data.​vanityAddress) {
         $.each(data.vanityAddress, function (index, value) {
            $('#addressLine' + (index + 1)).val(value);
         });
      }
      if (data.postcode) {
         $('#postcode').val(data.postcode);
      }
    }
  });
}); </script>
 
<script type="text/javascript">
   $.ajax({
      url: "//api.autoaddress.ie/2.0/verifyaddress",
      dataType: 'jsonp',
      jsonp: "callback",
      type: "GET",
      data: {
        key: "YOUR_KEY",
        address: "YOUR_ADDRESS",
        postcode: "YOUR_POSTCODE"
      }
   }).success(function (data) {
      //success code
   });
</script>
 

The Autoaddress jQuery plugin can be configured / toggled to search for addresses in different countries. To switch countries you just need to configure the country property as seen below.

<script type="text/javascript">
 $(function(){
    $("#myDiv").AutoAddress({
       key : "YOUR_KEY",
       country: "GB",
       onAddressFound: function (args) {
          if (args.postalAddress) {
            $.each(args.postalAddress, function (index, value) {
               $('#addressLine' + (index + 1)).val(value);
             });
          }
       }
    });
 });
</script>
 

For scenarios where the response includes residential and commercial results, you have the option to hide the commercial options and only display the residential options. This can be be achieved by setting displayBusinessListings to false.

<script type="text/javascript">
    $(function(){
       $("#myDiv").AutoAddress({
          key : "YOUR_KEY",
          displayBusinessListings : false
       });
    });
</script>
 

Using the onAddressFound(data) Callback, you can use the response data to auto-populate a sample form.

The Autoaddress jQuery Plugin can also search in ​Postally Compliant mode. To switch the control to search for ​Postal Addresses you just need to configure the vanityMode property to set to false and use the postalAddress in the response.

<script type="text/javascript">
$(function(){
   $("#myDiv").AutoAddress({
      key : "YOUR_KEY",
      vanityMode: false,
      onAddressFound: function (data) {
         if (data.postalAddress) {
            $.each(data.postalAddress, function (index, value) {
               $('#addressLine' + (index + 1)).val(value);
            });
         }
         if (data.postcode) {
            $('#postcode').val(data.postcode);
         }
       }
   });
});
</script>
 

Using the onAddressFound(data) Callback, you can use the response data to auto-populate a sample form.

The Autoaddress jQuery Plugin can also search in Geographic Address mode. To switch the control to search for Geographic Addresses you just need to configure the geographicAddress property to set to true and use the geographicAddress in the response.

<script type="text/javascript">
$(function(){
   $("#myDiv").AutoAddress({
      key : "YOUR_KEY",
      geographicAddress: true,
      onAddressFound: function (data) {
         if (data.geographicAddress) {
            $.each(data.geographicAddress, function (index, value) {
               $('#addressLine' + (index + 1)).val(value);
            });
         }
         if (data.postcode) {
            $('#postcode').val(data.postcode);
         }
       }
   });
});
</script>