Chrome for Android showing Auto-fill even if autocomplete: off

烈酒焚心 提交于 2019-12-04 20:09:58

Update (21-12-2017)

The old solution stopped working, so here is a new one.

The auto-fill is triggered with the following input tag:

<input type="search" name="To"  id="id_To" placeholder="a" class="autocomplete-city form-inner-field-city ui-autocomplete-input" autocomplete="off" maxlength="50" required="">

Key here are the fields name and id, which were the ones modified with the old solution. Apparently, Chrome identifies it as a field for Auto-fill. Thus, changing the name and id to something Chrome cannot identify seems to do the trick (for the moment).

For instance:

<input type="search" name="Dep"  id="id_Dep" placeholder="a" class="autocomplete-city form-inner-field-city ui-autocomplete-input" autocomplete="off" maxlength="50" required="">

OLD

Finally a solution that worked, from here:

It removes "name" and "id" attributes from elements and assigns them back after 1ms. Put this in document get ready.

$(document).ready(function() {
    $('form[autocomplete="off"] input, input[autocomplete="off"]').each(function () {

                var input = this;
                var name = $(input).attr('name');
                var id = $(input).attr('id');

                $(input).removeAttr('name');
                $(input).removeAttr('id');

                setTimeout(function () {
                    $(input).attr('name', name);
                    $(input).attr('id', id);
                }, 1);
            });
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!