Stop Chrome from suggesting Addresses with HTML while using Google Places Autofill

。_饼干妹妹 提交于 2020-12-15 06:39:41

问题


Given the following input:

 <input id="residential-address" placeholder="Residential Address" autocomplete="off" type="search" />

I continue to see addresses recommended:

[![enter image description here][1]][1]

I see that my browser setting tell Chrome to autofill, but then google's own location autocomplete widget UX becomes broken (with autofill overlapping the [autocomplete][2] widget).

[![enter image description here][3]][3]

What's the proper way to go about telling the browser to back off here?

Autocomplete code (works):

var initAutocomplete = function (inputId) {
    var autocomplete = new google.maps.places.Autocomplete(
        /** @type {!HTMLInputElement} */(document.getElementById(inputId)),
        { types: ['geocode'] });
    autocomplete.addListener('place_changed', function () { handleAddress(this) });
    return autocomplete;
}

Setting the autocomplete="new-password" doesn't work; I see it get reverted to off on load, and autofill persists.


回答1:


Simply changing the id to NOT include address is what fixed it for me. Thanks, Google, for injecting your opinions and random features into my projects and giving me more work. Stop trying to be "clever".



来源:https://stackoverflow.com/questions/54485995/stop-chrome-from-suggesting-addresses-with-html-while-using-google-places-autofi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!