autocomplete=“off” not working for Google Chrome

前端 未结 7 1007
日久生厌
日久生厌 2020-12-12 00:55

This question has been asked Several times in the past but unfortunately there\'s no way i could disable autofill for Google Chrome (v.36.0.1985.125 m)

I have alread

7条回答
  •  孤街浪徒
    2020-12-12 01:54

    Recent Version of Google Chrome are forcing Autofill irrespective of the Autocomplete=off . You are going to need little bit of hack here. Some of the previous hacks don't work anymore (34+ versions)

    I have tested following code on Google Chrome v36.

    It removes "name" and "id" attributes from elements and assigns them back after 1ms. This works perfectly in my case.

    Put this code in document 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);
                });
             });;
    

提交回复
热议问题