开发者

What would cause Chrome autofill to stop working?

开发者 https://www.devze.com 2023-04-01 20:32 出处:网络
I\'ve got a new site we\'re working that uses HTML5. Everything validates except for the LESS stylesheets and the Facebook tags. However, Chrome will not autofill properly. If I type \'chr\' in the fi

I've got a new site we're working that uses HTML5. Everything validates except for the LESS stylesheets and the Facebook tags. However, Chrome will not autofill properly. If I type 'chr' in the first name field, I get the standard Autofill drop down beneath it, but highlighting, click开发者_如何转开发ing, or otherwise selecting the autofill option does not complete the form as it should. The autofill dropdown merely goes away.

I'm guessing there's something in my HTML that is confusing the autofill code, but I can't seem to find any information on the web about Chrome's autofill implementation and things to look for when it doesn't work.

Edit: I know Autofill is working properly because it works on other sites, even other sites we've developed. It's got to be something specific to the HTML on this site.


Chrome will not save password or autocomplete data if a form is submitted asynchronously. For example, if you submit the following form, Chrome will prompt you to save the password:

<form action="/signin">
    <input type="text" name="email" />
    <input type="password" name="password" />
    <button type="submit">Sign In</button>
</form>

However, if you bind to the submit event and override the default behavior, there will be no prompt and the autocomplete data won't be saved:

$(function(){
    $('form').submit(function(e){
        e.preventDefault();
        $.post($(this).attr('action'), $(this).serialize());
    });
});

Tested in 20.0


It seems that Chrome only enables the autofill for forms with a POST method. This may have been a security update on a recent version.

Autofill will work if you do:

<form id="myForm" action="?go" method="post">

It won't work if you omit the method or it's set to get:

<form id="myForm" action="?go" method="get">

<form id="myForm" action="?go">


The only way I know of in HTML to block it is setting: autocomplete="off" on the inputs.

I know drop downs don't work sometimes with autofill, but not text boxes.


I have just fighted with this issue for a while, I found out that a "name" attribute with a dash like "email-2" would cause Chrome not to autocomplete the field. In my case I have changed it to email2 and now it works. It only affects the "name" attribute, while the "id" attribute does not make any difference.

I hope this help someone to save time with such a silly bug.

Greetings from Argentina!


Sorry I can't give you a definitive answer, but I would start with removing everything from the page except that input field. If it works then I would start "binary search" - remove half of the original layout and see if it works, if it isn't - remove another half of what's left and so on, until problem line is found.

Same could be applied to css, js, etc. It is a pretty effective way of searching for errors (for 1024 lines of code you will find exact problem line in just 10 steps).


Only Those elements which require autofill should be there inside the form.otherwise the autofill wont work.Bring only those textboxes under a form.if u already have form involving other elements,separate them and put new form tag around the textboxes which require autofill and nothing else inside it.

0

精彩评论

暂无评论...
验证码 换一张
取 消