<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Real time street address lookup in form field in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/773914#M33477</link>
    <description>&lt;P&gt;I know this is an old thread but I stumbled across it when I was trying to figure this out so I figured I'd share my solution:&lt;BR /&gt;&lt;BR /&gt;This can be done with Google Maps API. I'll do my best to explain it below, but you can also hire my agency to do it for you if you'd rather not bother with it (SimpleStrat.com).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do this, you'll need to add the javascript below to the page where your form will appear. There's also a way to add it to the form embed code directly but I won't get into that here. There are a couple things you'll likely need to edit depending on your form and the fields you want filled in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code is currently set up to work for US and Canada is based on the code found on this page:&amp;nbsp;&lt;A href="https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform&lt;/A&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;// Create the script tag, set the appropriate attributes, be sure to replace "YOURAPIKEY" in the script source url with your Google Maps API Key
var script = document.createElement('script');
script.src='https://maps.googleapis.com/maps/api/js?key=YOURAPIKEY&amp;amp;libraries=places&amp;amp;callback=initAutocomplete';
script.async = true;

// Append the 'script' element to 'head' after the page loads 
window.addEventListener('load', function(){document.head.appendChild(script);})

let autocomplete;
let address1Field;
let address2Field;
let postalField;

function initAutocomplete() {
  //change .hs-address below to the class for your 1st line
  //address input field if necessary
  address1Field = document.querySelector(".hs-address .hs-input");
  //change .hs-zip below to the class for your postal code input field if necessary 
  postalField = document.querySelector(".hs-zip .hs-input");
  // Create the autocomplete object, restricting the search predictions to
  // addresses in the US and Canada.
  autocomplete = new google.maps.places.Autocomplete(address1Field, {
    componentRestrictions: { country: ["us", "ca"] },
    fields: ["address_components", "geometry"],
    types: ["address"],
  });
  // When the user selects an address from the drop-down, populate the address fields in the form.
  autocomplete.addListener("place_changed", fillInAddress);
}

function fillInAddress() {
  // Get the place details from the autocomplete object.
  const place = autocomplete.getPlace();
  let address1 = "";
  let postcode = "";

  // Get each component of the address from the place details,
  // and then fill-in the corresponding field on the form.
  // place.address_components are google.maps.GeocoderAddressComponent objects
  // which are documented at http://goo.gle/3l5i5Mr
  for (const component of place.address_components) {
    // &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/5004"&gt;@TS&lt;/a&gt;-ignore remove once typings fixed
    const componentType = component.types[0];

    switch (componentType) {
      case "street_number": {
        address1 = `${component.long_name} ${address1}`;
        break;
      }

      case "route": {
        address1 += component.short_name;
        break;
      }

      case "postal_code": {
        postcode = `${component.long_name}${postcode}`;
        break;
      }

      case "postal_code_suffix": {
        postcode = `${postcode}-${component.long_name}`;
        break;
      }
      case "locality":
        //change .hs-city below to the class for your city input field if necessary
        //comment out or delete the line below if no city field in your form
        document.querySelector(".hs-city .hs-input").value = component.long_name; 
        break;
      case "administrative_area_level_1": {
        //change .hs-state below to the class for your city input field if necessary
        //comment out or delete the line below if no state field in your form
        document.querySelector(".hs-state .hs-input").value = component.short_name;
        break;
      }
      case "country":
        //change .hs-country below to the class for your city input field if necessary
        //comment out or delete the line below if no country field in your form
        document.querySelector(".hs-country .hs-input").value = component.long_name;
        break;
    }
  }

  address1Field.value = address1;
  //comment out or delete the line below if no postal code field in form
  postalField.value = postcode;
}

window.initAutocomplete = initAutocomplete;&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 24 Mar 2023 21:40:01 GMT</pubDate>
    <dc:creator>tsprunk</dc:creator>
    <dc:date>2023-03-24T21:40:01Z</dc:date>
    <item>
      <title>Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/218975#M9981</link>
      <description>&lt;P&gt;I am creating a simple registration form containing email, first name, last name, phone number, and street address fields.&amp;nbsp; For the street address, I would like to add real time autocomplete/lookup functionality, using the smartystreets API documented here: &lt;A href="https://smartystreets.com/docs/plugins/website" target="_blank"&gt;https://smartystreets.com/docs/plugins/website&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to hubspot development, and not really sure where to start with this, or how it would be structured.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 20:01:59 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/218975#M9981</guid>
      <dc:creator>chrispower</dc:creator>
      <dc:date>2018-11-29T20:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/219639#M10082</link>
      <description>&lt;P&gt;Unfortunately I'm not familiar with smarty streets, but if your not married to that option, you could use the google maps autocomplete api.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a pretty good tutorial on it : &lt;A href="https://www.w3docs.com/learn-javascript/places-autocomplete.html" target="_blank"&gt;https://www.w3docs.com/learn-javascript/places-autocomplete.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You would just need to set the script to target the ID of the hubspot form field.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 21:48:02 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/219639#M10082</guid>
      <dc:creator>joneichler</dc:creator>
      <dc:date>2018-12-04T21:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/219790#M10107</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am actually already familiar with smartystreets and have implemented it elsewhere in standalone websites.&amp;nbsp; The part I'm not clear on is how I would integrate it with a hubspot form.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"You would just need to set the script to target the ID of the hubspot form field."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you elaborate on that please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 16:27:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/219790#M10107</guid>
      <dc:creator>chrispower</dc:creator>
      <dc:date>2018-12-05T16:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/219791#M10108</link>
      <description>&lt;P&gt;With the google solution you just target a specific Form field (using standard css targeting) to be your main address field and then you also set which fields it will poplulate once the user selects the address.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I can't be of more assistance.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 16:31:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/219791#M10108</guid>
      <dc:creator>joneichler</dc:creator>
      <dc:date>2018-12-05T16:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/299119#M14124</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/8079"&gt;@joneichler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This sounds like a great solution I think a lot of people would utilize. Would you mind sharing a bit more about how you accomplished this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The link you shared doesn;t contain any info about filling the remaining address fields with the info retrieved from the Places API.&amp;nbsp; Would you mind sharing your implementation? Even a brief example of some working code would go a long way.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 20:53:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/299119#M14124</guid>
      <dc:creator>alanbrown</dc:creator>
      <dc:date>2019-10-28T20:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/319167#M15369</link>
      <description>&lt;P&gt;Did you ever receive any additional instructions?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 21:41:41 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/319167#M15369</guid>
      <dc:creator>SabeFlex</dc:creator>
      <dc:date>2020-02-13T21:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/370427#M18606</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/76947"&gt;@chrispower&lt;/a&gt;&amp;nbsp;and &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/8079"&gt;@joneichler&lt;/a&gt;&amp;nbsp;and &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/74577"&gt;@SabeFlex&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please upvote this idea here so HubSpot will do this for us &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hubspot.com/t5/HubSpot-Ideas/Autocomplete-adress-form-fields-with-Google-maps/idi-p/247511" target="_blank"&gt;https://community.hubspot.com/t5/HubSpot-Ideas/Autocomplete-adress-form-fields-with-Google-maps/idi-p/247511&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Sep 2020 14:50:01 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/370427#M18606</guid>
      <dc:creator>jkeough78</dc:creator>
      <dc:date>2020-09-15T14:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/437060#M23047</link>
      <description>&lt;P&gt;Wondering if anyone ever got SmartyStreets intergrated with HubSpot.&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 03:35:21 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/437060#M23047</guid>
      <dc:creator>BrandonCarn</dc:creator>
      <dc:date>2021-05-13T03:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/511041#M25579</link>
      <description>&lt;P&gt;Hi, you can add Loqate's address autocomplete on HubSpot forms, and here's a handy guide to show you how to:&amp;nbsp;&lt;A href="https://www.loqate.com/resources/support/setup-guides/hubspot/" target="_blank"&gt;https://www.loqate.com/resources/support/setup-guides/hubspot/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 12:21:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/511041#M25579</guid>
      <dc:creator>Mireille</dc:creator>
      <dc:date>2021-10-15T12:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/773914#M33477</link>
      <description>&lt;P&gt;I know this is an old thread but I stumbled across it when I was trying to figure this out so I figured I'd share my solution:&lt;BR /&gt;&lt;BR /&gt;This can be done with Google Maps API. I'll do my best to explain it below, but you can also hire my agency to do it for you if you'd rather not bother with it (SimpleStrat.com).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do this, you'll need to add the javascript below to the page where your form will appear. There's also a way to add it to the form embed code directly but I won't get into that here. There are a couple things you'll likely need to edit depending on your form and the fields you want filled in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code is currently set up to work for US and Canada is based on the code found on this page:&amp;nbsp;&lt;A href="https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform&lt;/A&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;// Create the script tag, set the appropriate attributes, be sure to replace "YOURAPIKEY" in the script source url with your Google Maps API Key
var script = document.createElement('script');
script.src='https://maps.googleapis.com/maps/api/js?key=YOURAPIKEY&amp;amp;libraries=places&amp;amp;callback=initAutocomplete';
script.async = true;

// Append the 'script' element to 'head' after the page loads 
window.addEventListener('load', function(){document.head.appendChild(script);})

let autocomplete;
let address1Field;
let address2Field;
let postalField;

function initAutocomplete() {
  //change .hs-address below to the class for your 1st line
  //address input field if necessary
  address1Field = document.querySelector(".hs-address .hs-input");
  //change .hs-zip below to the class for your postal code input field if necessary 
  postalField = document.querySelector(".hs-zip .hs-input");
  // Create the autocomplete object, restricting the search predictions to
  // addresses in the US and Canada.
  autocomplete = new google.maps.places.Autocomplete(address1Field, {
    componentRestrictions: { country: ["us", "ca"] },
    fields: ["address_components", "geometry"],
    types: ["address"],
  });
  // When the user selects an address from the drop-down, populate the address fields in the form.
  autocomplete.addListener("place_changed", fillInAddress);
}

function fillInAddress() {
  // Get the place details from the autocomplete object.
  const place = autocomplete.getPlace();
  let address1 = "";
  let postcode = "";

  // Get each component of the address from the place details,
  // and then fill-in the corresponding field on the form.
  // place.address_components are google.maps.GeocoderAddressComponent objects
  // which are documented at http://goo.gle/3l5i5Mr
  for (const component of place.address_components) {
    // &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/5004"&gt;@TS&lt;/a&gt;-ignore remove once typings fixed
    const componentType = component.types[0];

    switch (componentType) {
      case "street_number": {
        address1 = `${component.long_name} ${address1}`;
        break;
      }

      case "route": {
        address1 += component.short_name;
        break;
      }

      case "postal_code": {
        postcode = `${component.long_name}${postcode}`;
        break;
      }

      case "postal_code_suffix": {
        postcode = `${postcode}-${component.long_name}`;
        break;
      }
      case "locality":
        //change .hs-city below to the class for your city input field if necessary
        //comment out or delete the line below if no city field in your form
        document.querySelector(".hs-city .hs-input").value = component.long_name; 
        break;
      case "administrative_area_level_1": {
        //change .hs-state below to the class for your city input field if necessary
        //comment out or delete the line below if no state field in your form
        document.querySelector(".hs-state .hs-input").value = component.short_name;
        break;
      }
      case "country":
        //change .hs-country below to the class for your city input field if necessary
        //comment out or delete the line below if no country field in your form
        document.querySelector(".hs-country .hs-input").value = component.long_name;
        break;
    }
  }

  address1Field.value = address1;
  //comment out or delete the line below if no postal code field in form
  postalField.value = postcode;
}

window.initAutocomplete = initAutocomplete;&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Mar 2023 21:40:01 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/773914#M33477</guid>
      <dc:creator>tsprunk</dc:creator>
      <dc:date>2023-03-24T21:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/866654#M36340</link>
      <description>&lt;P&gt;Hi! Wondering if you have a live form running off of this? I've got a version running using places now but there are a few quirks I'd like to iron out; would love to see if yours runs more smoothly?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 22:14:26 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/866654#M36340</guid>
      <dc:creator>apmul</dc:creator>
      <dc:date>2023-10-18T22:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/1114294#M42270</link>
      <description>&lt;P&gt;Yes! This is very possible with Smarty (formerly SmartyStreets) in Hubspot. You'll create a custom HTML form that communicates to Hubspot through the form API.&lt;BR /&gt;&lt;BR /&gt;It sounds complicated, and it kind of is, but not really.&lt;BR /&gt;&lt;BR /&gt;Smarty released a tutorial on it last year:&amp;nbsp;&lt;A href="https://www.smarty.com/articles/hubspot-address-autocomplete-guide" target="_blank"&gt;https://www.smarty.com/articles/hubspot-address-autocomplete-guide&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Basically, you create an HTML form, link it to the Hubspot form API, and then connect it to Smarty's autocomplete functionality. Pretty simple.&lt;BR /&gt;&lt;BR /&gt;Here's basic code for an HTML form that is prepared for autocomplete:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;form id="myCoolForm" style="padding: 30px; border: 1px solid #476884; border-radius: 16px;"&amp;gt;&amp;lt;input id="myCoolFirstname" style="padding: 15px; margin: 6px; border: 2px solid #eee; border-radius: 2px;" type="text" placeholder="First name *"&amp;gt; &amp;lt;input id="myCoolLastname" style="padding: 15px; margin: 6px; border: 2px solid #eee; border-radius: 2px;" type="text" placeholder="Last name *"&amp;gt; &amp;lt;input id="myCoolEmail" style="padding: 15px; margin: 6px; border: 2px solid #eee; border-radius: 2px;" required="" type="text" placeholder="Email *"&amp;gt; &amp;lt;input id="myCoolAddress" style="padding: 15px; margin: 6px; border: 2px solid #eee; border-radius: 2px;" type="text" placeholder="Address *"&amp;gt; &amp;lt;input id="myCoolCity" style="padding: 15px; margin: 6px; border: 2px solid #eee; border-radius: 2px;" type="text" placeholder="City *"&amp;gt;&amp;lt;select id="myCoolState" style="padding: 15px; margin: 6px; border: 2px solid #eee; border-radius: 2px;"&amp;gt;
		&amp;lt;option value="AL"&amp;gt;AL&amp;lt;/option&amp;gt;
		&amp;lt;option value="AK"&amp;gt;AK&amp;lt;/option&amp;gt;
		&amp;lt;option value="AZ"&amp;gt;AZ&amp;lt;/option&amp;gt;
		&amp;lt;option value="AR"&amp;gt;AR&amp;lt;/option&amp;gt;
		&amp;lt;option value="CA"&amp;gt;CA&amp;lt;/option&amp;gt;
		&amp;lt;option value="CO"&amp;gt;CO&amp;lt;/option&amp;gt;
		&amp;lt;option value="CT"&amp;gt;CT&amp;lt;/option&amp;gt;
		&amp;lt;option value="DE"&amp;gt;DE&amp;lt;/option&amp;gt;
		&amp;lt;option value="FL"&amp;gt;FL&amp;lt;/option&amp;gt;
		&amp;lt;option value="GA"&amp;gt;GA&amp;lt;/option&amp;gt;
		&amp;lt;option value="HI"&amp;gt;HI&amp;lt;/option&amp;gt;
		&amp;lt;option value="ID"&amp;gt;ID&amp;lt;/option&amp;gt;
		&amp;lt;option value="IL"&amp;gt;IL&amp;lt;/option&amp;gt;
		&amp;lt;option value="IN"&amp;gt;IN&amp;lt;/option&amp;gt;
		&amp;lt;option value="IA"&amp;gt;IA&amp;lt;/option&amp;gt;
		&amp;lt;option value="KS"&amp;gt;KS&amp;lt;/option&amp;gt;
		&amp;lt;option value="KY"&amp;gt;KY&amp;lt;/option&amp;gt;
		&amp;lt;option value="LA"&amp;gt;LA&amp;lt;/option&amp;gt;
		&amp;lt;option value="ME"&amp;gt;ME&amp;lt;/option&amp;gt;
		&amp;lt;option value="MD"&amp;gt;MD&amp;lt;/option&amp;gt;
		&amp;lt;option value="MA"&amp;gt;MA&amp;lt;/option&amp;gt;
		&amp;lt;option value="MI"&amp;gt;MI&amp;lt;/option&amp;gt;
		&amp;lt;option value="MN"&amp;gt;MN&amp;lt;/option&amp;gt;
		&amp;lt;option value="MS"&amp;gt;MS&amp;lt;/option&amp;gt;
		&amp;lt;option value="MO"&amp;gt;MO&amp;lt;/option&amp;gt;
		&amp;lt;option value="MT"&amp;gt;MT&amp;lt;/option&amp;gt;
		&amp;lt;option value="NE"&amp;gt;NE&amp;lt;/option&amp;gt;
		&amp;lt;option value="NV"&amp;gt;NV&amp;lt;/option&amp;gt;
		&amp;lt;option value="NH"&amp;gt;NH&amp;lt;/option&amp;gt;
		&amp;lt;option value="NJ"&amp;gt;NJ&amp;lt;/option&amp;gt;
		&amp;lt;option value="NM"&amp;gt;NM&amp;lt;/option&amp;gt;
		&amp;lt;option value="NY"&amp;gt;NY&amp;lt;/option&amp;gt;
		&amp;lt;option value="NC"&amp;gt;NC&amp;lt;/option&amp;gt;
		&amp;lt;option value="ND"&amp;gt;ND&amp;lt;/option&amp;gt;
		&amp;lt;option value="OH"&amp;gt;OH&amp;lt;/option&amp;gt;
		&amp;lt;option value="OK"&amp;gt;OK&amp;lt;/option&amp;gt;
		&amp;lt;option value="OR"&amp;gt;OR&amp;lt;/option&amp;gt;
		&amp;lt;option value="PA"&amp;gt;PA&amp;lt;/option&amp;gt;
		&amp;lt;option value="RI"&amp;gt;RI&amp;lt;/option&amp;gt;
		&amp;lt;option value="SC"&amp;gt;SC&amp;lt;/option&amp;gt;
		&amp;lt;option value="SD"&amp;gt;SD&amp;lt;/option&amp;gt;
		&amp;lt;option value="TN"&amp;gt;TN&amp;lt;/option&amp;gt;
		&amp;lt;option value="TX"&amp;gt;TX&amp;lt;/option&amp;gt;
		&amp;lt;option value="UT"&amp;gt;UT&amp;lt;/option&amp;gt;
		&amp;lt;option value="VT"&amp;gt;VT&amp;lt;/option&amp;gt;
		&amp;lt;option value="VA"&amp;gt;VA&amp;lt;/option&amp;gt;
		&amp;lt;option value="WA"&amp;gt;WA&amp;lt;/option&amp;gt;
		&amp;lt;option value="WV"&amp;gt;WV&amp;lt;/option&amp;gt;
		&amp;lt;option value="WI"&amp;gt;WI&amp;lt;/option&amp;gt;
		&amp;lt;option value="WY"&amp;gt;WY&amp;lt;/option&amp;gt;
	&amp;lt;/select&amp;gt;&amp;lt;input id="myCoolZip" style="padding: 15px; margin: 6px; border: 2px solid #eee; border-radius: 2px;" type="text" placeholder="ZIP Code"&amp;gt;
	&amp;lt;div style="padding-bottom: 15px; padding-left: 15px;"&amp;gt;Your &amp;lt;a href="https://YOUR PRIVACY POLICY LINK GOES HERE"&amp;gt;privacy&amp;lt;/a&amp;gt; is important to us. You agree to receive messages regarding our products and services by submitting this form. You may unsubscribe at any time.&amp;lt;/div&amp;gt;
	&amp;lt;div style="text-align: center;"&amp;gt;&amp;lt;button id="myCoolButton" style="background-color: #0066ff; color: white; padding: 15px 40px; font-size: 20px; font-weight: bold; border: none; border-radius: 90px; cursor: pointer; display: inline-block; text-align: center; text-decoration: none;"&amp;gt;SUBMIT&amp;lt;/button&amp;gt;&amp;lt;/div&amp;gt;
	&amp;lt;/form&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then whatever page you're putting it on just needs to have this JavaScript in the footer.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;

		// HubSpot Settings - change stuff between the quotes after the equals sign (keep the quotes).
		const MY_COOL_HUBSPOT_FORM_ID = 'YOUR HUBSPOT FORM ID';
		const MY_COOL_HUBSPOT_PORTAL_ID = 'YOUR HUBSPOT PORTAL ID';
		const MY_COOL_CONFIRMATION_PAGE = 'YOUR CONFIRMATION PAGE URL BEGINNING WITH https://';
		const MY_COOL_ERROR_MESSAGE = 'All fields are required.';
		// Smarty Settings - change stuff between the quotes after the equals sign (keep the quotes).
		const MY_COOL_SMARTY_EMBEDDED_KEY = 'YOUR SMARTY EMBEDDED KEY GOES HERE';
		const MY_COOL_SMARTY_SOURCE = 'postal'; // valid options are 'postal' or 'all'

		// ------ DON'T MODIFY BELOW THIS LINE ------

		document.getElementById('myCoolButton').addEventListener('click', (e) =&amp;gt; {
			e.preventDefault();
			submitData();
		});
		async function submitData() {
			const url = `https://api.hsforms.com/submissions/v3/integration/submit/${MY_COOL_HUBSPOT_PORTAL_ID}/${MY_COOL_HUBSPOT_FORM_ID}`;
			const headers = {
				'accept': 'application/json',
				'content-type': 'application/json',
			};
			const data = {
				"fields": [{
					"name": "firstname",
					"value": document.getElementById('myCoolFirstname').value
				},
					{
						"name": "lastname",
						"value": document.getElementById('myCoolLastname').value
					},
					{
						"name": "email",
						"value": document.getElementById('myCoolEmail').value
					},
					{
						"name": "address",
						"value": document.getElementById('myCoolAddress').value
					},
					{
						"name": "city",
						"value": document.getElementById('myCoolCity').value
					},
					{
						"name": "state",
						"value": document.getElementById('myCoolState').value
					},
					{
						"name": "zip",
						"value": document.getElementById('myCoolZip').value
					}
				],
				"skipValidation": false,
				"context": {}
			};
			try {
				const response = await fetch(url, {
					method: 'POST',
					headers: headers,
					body: JSON.stringify(data)
				});
				if (!response.ok) {
					throw new Error(`HTTP error! status: ${response.status}`);
				}
				const responseData = await response.json();
				console.log(responseData);
				window.location.href = MY_COOL_CONFIRMATION_PAGE;
			} catch (error) {
				console.error('Error:', error);
				alert(MY_COOL_ERROR_MESSAGE);
			}
		}

		((global) =&amp;gt; {
			let settings = {
				embeddedKey: '',
				addressId: 'address',
				cityId: 'city',
				stateId: 'state',
				zipCodeId: 'zip',
				styleBackgroundColorHexString: '#fff',
				styleColorHexString: '#333',
				styleHoverBackgroundColorHexString: '#cfe8ff',
				styleHoverColorHexString: '#000',
				styleBorderColorHexString: '#e0e0e0',
				styleBorderPixelWidthInt: 2,
				styleBorderRadiusInt: 8,
				styleFontFamilyString: 'sans-serif',
				styleFontSizePixelInt: 14,
				styleRowPaddingString: '8px',
				styleBoxPixelWidthInt: 300,
				styleBoxPixelHeightInt: 300,
				styleSelectedSuggestionColorHexString: '#000',
				styleSelectedSuggestionBackgroundColorHexString: '#ddd',
				suggestionElement: document.createElement('div'),
				suggestionId: null,
				offsetHeight: 20,
				addressElement: null,
				activeStyles: '',
				inactiveStyles: 'display: none;',
				selectedIndex: 0,
				lastAction: '',
			};
			const wrapperStyles = `
				display: inline-block;
				position: relative;
				width: 100%;
			`;
			const extendSettings = (defaults, options) =&amp;gt; {
				// @todo ensure the options are allowed.
				return {
					...defaults,
					...options
				};
			};
			const wrapElementsWithDiv = (elementId) =&amp;gt; {
				const knownElement = document.getElementById(elementId);
				if (!knownElement) {
					console.error(`Element with ID ${elementId} not found.`);
					return;
				}
				settings.addressElement = knownElement;
				settings.offsetHeight = knownElement.offsetHeight;
				const wrapperDiv = document.createElement('div');
				wrapperDiv.style.cssText = wrapperStyles;
				knownElement.parentNode.insertBefore(wrapperDiv, knownElement);
				wrapperDiv.appendChild(knownElement);
				knownElement.parentNode.insertBefore(settings.suggestionElement, knownElement.nextSibling);
			}
			const sendLookupRequest = async (searchValue, selected = "") =&amp;gt; {
				const params = new URLSearchParams({
					key: settings.embeddedKey,
					search: searchValue,
					source: MY_COOL_SMARTY_SOURCE,
					selected
				});
				try {
					const request = await fetch(
						`https://us-autocomplete-pro.api.smarty.com/lookup?${params}`
					);
					const data = await request.json();
					if (data?.suggestions?.length &amp;gt; 0) formatSuggestions(data.suggestions);
				} catch (e) {
					console.error(e.message);
				}
			};
			const applyStyles = (element, styles) =&amp;gt; {
				for (let property in styles) {
					element.style[property] = styles[property];
				}
			};
			const formatSuggestions = (suggestions) =&amp;gt; {
				const {
					suggestionElement,
					inactiveStyles,
					styleRowPaddingString,
					styleHoverBackgroundColorHexString,
					styleHoverColorHexString,
					styleBackgroundColorHexString,
					styleColorHexString,
					styleFontSizePixelInt,
					styleSelectedSuggestionColorHexString,
					styleSelectedSuggestionBackgroundColorHexString,
					activeStyles,
				} = settings;
				suggestionElement.innerHTML = '';
				suggestionElement.style.cssText = activeStyles;
				const formattedSuggestions = suggestions.map((suggestion, index) =&amp;gt; {
					const divElement = document.createElement("div");
					divElement.classList.add('smarty-suggestion');
					divElement.style['padding'] = styleRowPaddingString;
					divElement.style['fontSize'] = `${styleFontSizePixelInt}px`;
					if (index === 0) {
						applyStyles(divElement, {
							color: styleSelectedSuggestionColorHexString,
							backgroundColor: styleSelectedSuggestionBackgroundColorHexString,
						});
						settings.selectedIndex = 0;
					}
					const {
						street_line,
						city,
						state,
						zipcode,
						secondary,
						entries
					} = suggestion;
					const hasSecondaryData = secondary &amp;amp;&amp;amp; entries &amp;gt; 1;
					divElement.innerText = `${street_line} ${secondary} ${
						hasSecondaryData ? `(${entries} entries)` : ""
					} ${city} ${state} ${zipcode}`;
					divElement.addEventListener('mouseover', () =&amp;gt; {
						if (settings.lastAction === 'keyboard') return;
						applyStyles(divElement, {
							backgroundColor: styleHoverBackgroundColorHexString,
							color: styleHoverColorHexString,
						});
					});
					divElement.addEventListener('mouseout', () =&amp;gt; {
						applyStyles(divElement, {
							backgroundColor: styleBackgroundColorHexString,
							color: styleColorHexString,
						});
					});
					divElement.addEventListener("click", async () =&amp;gt; {
						const streetLineWithSecondary = `${street_line} ${secondary}`.trim();
						if (hasSecondaryData) {
							const selected = `${streetLineWithSecondary} (${entries}) ${city} ${state} ${zipcode}`;
							await sendLookupRequest(streetLineWithSecondary, selected);
						} else {
							suggestionElement.style.cssText = inactiveStyles;
						}
						populateForm({
							streetLineWithSecondary,
							city,
							state,
							zipcode
						});
					});
					return divElement;
				});
				suggestionElement.append(...formattedSuggestions);
			}
			const populateForm = ({
				streetLineWithSecondary,
				city,
				state,
				zipcode
			}) =&amp;gt; {
				const {
					addressId,
					cityId,
					stateId,
					zipCodeId
				} = settings;
				document.getElementById(addressId).value = streetLineWithSecondary;
				document.getElementById(cityId).value = city;
				document.getElementById(stateId).value = state;
				document.getElementById(zipCodeId).value = zipcode;
			};
			const scrollWrapperToSelected = () =&amp;gt; {
				const {
					selectedIndex,
					suggestionElement
				} = settings;
				const elements = document.getElementsByClassName('smarty-suggestion');
				if (selectedIndex &amp;gt;= 0 &amp;amp;&amp;amp; selectedIndex &amp;lt; elements.length) {
					const selectedChild = elements[selectedIndex];
					const wrapperRect = suggestionElement.getBoundingClientRect();
					const selectedRect = selectedChild.getBoundingClientRect();
					// Check if selected child is above the viewport
					if (selectedRect.top &amp;lt; wrapperRect.top) {
						suggestionElement.scrollTop -= (wrapperRect.top - selectedRect.top);
					}
					// Check if selected child is below the viewport
					else if (selectedRect.bottom &amp;gt; wrapperRect.bottom) {
						suggestionElement.scrollTop += (selectedRect.bottom - wrapperRect.bottom);
					}
				}
			}
			LikeButtaSmartyUsAddressAutocomplete = (userSettings) =&amp;gt; {
				settings = extendSettings(settings, userSettings);
				wrapElementsWithDiv(settings.addressId);
				settings.activeStyles = `
					display: block;
					position: absolute;
					overflow-y: auto;
					cursor: pointer;
					top: ${settings.offsetHeight};
					width: ${settings.styleBoxPixelWidthInt}px;
					height: ${settings.styleBoxPixelHeightInt}px;
					border: solid ${settings.styleBorderPixelWidthInt}px ${settings.styleBorderColorHexString};
					border-radius: ${settings.styleBorderRadiusInt}px;
					background-color: ${settings.styleBackgroundColorHexString};
					font-family: ${settings.styleFontFamilyString};
					color: ${settings.styleColorHexString};
				`;
				settings.suggestionElement.id = 'smartySuggestionBox';
				settings.suggestionId = settings.suggestionElement.id;
				const {
					addressElement,
					suggestionElement,
					inactiveStyles,
					activeStyles
				} = settings;
				suggestionElement.style.cssText = inactiveStyles;
				addressElement.addEventListener("keyup", (e) =&amp;gt; {
					if ([
						'Shift', 'Control', 'Alt', 'Meta', 'CapsLock', 'Tab', 'ArrowUp', 'ArrowDown',
						'ArrowLeft', 'ArrowRight', 'Escape', 'F1', 'F2', 'F3', 'F4', 'F5',
						'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12'
					].includes(e.key)) return;
					if (e.key === 'Enter') {
						const elements = document.getElementsByClassName('smarty-suggestion');
						elements[settings.selectedIndex].click();
						return;
					}
					const searchValue = e.target.value;
					if (!searchValue) {
						suggestionElement.style.cssText = inactiveStyles;
						return;
					}
					sendLookupRequest(searchValue);
				});
				addressElement.addEventListener("keydown", async (e) =&amp;gt; {
					if (!['ArrowUp', 'ArrowDown'].includes(e.key)) return;
					e.preventDefault();
					const {
						selectedIndex,
						styleColorHexString,
						styleBackgroundColorHexString,
						styleSelectedSuggestionColorHexString,
						styleSelectedSuggestionBackgroundColorHexString,
					} = settings;
					const elements = document.getElementsByClassName('smarty-suggestion');
					[...elements].forEach((element) =&amp;gt; {
						applyStyles(element, {
							color: styleColorHexString,
							backgroundColor: styleBackgroundColorHexString,
						});
					});
					if (elements.length === selectedIndex + 1 &amp;amp;&amp;amp; e.key === 'ArrowDown') {
						settings.selectedIndex = 0;
					} else if (selectedIndex === 0 &amp;amp;&amp;amp; e.key === 'ArrowUp') {
						settings.selectedIndex = elements.length - 1;
					} else if (e.key === 'ArrowDown') {
						settings.selectedIndex += 1;
					} else {
						settings.selectedIndex -= 1;
					}
					applyStyles(elements[settings.selectedIndex], {
						color: styleSelectedSuggestionColorHexString,
						backgroundColor: styleSelectedSuggestionBackgroundColorHexString,
					});
					settings.lastAction = 'keyboard';
					scrollWrapperToSelected();
				});
				suggestionElement.addEventListener('mousemove', (e) =&amp;gt; {
					settings.lastAction = 'mouse';
				});
				suggestionElement.addEventListener('mouseout', (e) =&amp;gt; {
					const elements = document.getElementsByClassName('smarty-suggestion');
					const {
						selectedIndex,
						styleSelectedSuggestionColorHexString,
						styleSelectedSuggestionBackgroundColorHexString
					} = settings;
					applyStyles(elements[selectedIndex], {
						color: styleSelectedSuggestionColorHexString,
						backgroundColor: styleSelectedSuggestionBackgroundColorHexString,
					});
				});
				document.addEventListener('click', (e) =&amp;gt; {
					if (!suggestionElement.contains(e.target) &amp;amp;&amp;amp; !e.target.classList.contains('smarty-suggestion')) {
						suggestionElement.style.cssText = inactiveStyles;
					}
				});
			};
			global.LikeButtaSmartyUsAddressAutocomplete = LikeButtaSmartyUsAddressAutocomplete;
		})(window);
		LikeButtaSmartyUsAddressAutocomplete({
			embeddedKey: MY_COOL_SMARTY_EMBEDDED_KEY,
			addressId: 'myCoolAddress',
			cityId: 'myCoolCity',
			stateId: 'myCoolState',
			zipCodeId: 'myCoolZip',
		});
	&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got it working really fast, in like ten minutes.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 16:16:33 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/1114294#M42270</guid>
      <dc:creator>atownsend1</dc:creator>
      <dc:date>2025-02-25T16:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/1114295#M42271</link>
      <description>&lt;P&gt;I did, and it works great. They have a handy guide to show you how:&amp;nbsp;&lt;A href="https://www.smarty.com/articles/hubspot-address-autocomplete-guide" target="_blank"&gt;https://www.smarty.com/articles/hubspot-address-autocomplete-guide&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 16:20:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/1114295#M42271</guid>
      <dc:creator>atownsend1</dc:creator>
      <dc:date>2025-02-25T16:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/1114296#M42272</link>
      <description>&lt;P&gt;Smarty (formerly SmartyStreets) recently released a tutorial on how to get autocomplete working in Hubspot, and the principles outlined in their tutorial answer the question above.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.smarty.com/articles/hubspot-address-autocomplete-guide" target="_blank"&gt;https://www.smarty.com/articles/hubspot-address-autocomplete-guide&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 16:22:25 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/1114296#M42272</guid>
      <dc:creator>atownsend1</dc:creator>
      <dc:date>2025-02-25T16:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Real time street address lookup in form field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/1114366#M42276</link>
      <description>&lt;P&gt;I think this would solve your problem:&amp;nbsp;&lt;A href="https://www.smarty.com/articles/hubspot-address-autocomplete-guide" target="_blank"&gt;https://www.smarty.com/articles/hubspot-address-autocomplete-guide&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2025 18:40:02 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Real-time-street-address-lookup-in-form-field/m-p/1114366#M42276</guid>
      <dc:creator>atownsend1</dc:creator>
      <dc:date>2025-02-25T18:40:02Z</dc:date>
    </item>
  </channel>
</rss>

