Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<input autocomplete='on'> does not work with Chrome. Is it a bug?

I was struggling for a while on the html5 autocomplete feature of Chrome. I had a form like this

<form>
<input name='myname' type='email' autocomplete='on' />
<input type='submit' value='Submit!' onclick='transform_and_post_data();return false;'/>
</form>

When using Firefox and returning to this form autocomplete works fine. But not with Chrome (versions 26 to 30 at least). I finally found that autocomplete saving of a form is done only when calling the GET or POST default action of the form (here prevented by the return false). So I found a work around that fixes it in some situations :

 <form method='post' action='myaction'>
 <input name='myname' type='email' autocomplete='on' />
<input type='submit' value='Submit!' onclick='transform_data();'/>
</form>

This works well as long as I do not need to post my form data through an XhttpRequest. Does any one knows a trick to make Chrome autocomplete forms with XHRs?

Is it a known bug of Chrome? (as Firefox works as expected)

Note : autocomplete='on' should be useless because it is the default behaviour of an input

like image 407
frank Avatar asked Oct 13 '13 13:10

frank


People also ask

Why does autocomplete not work in Chrome?

Chrome respects autocomplete=off only when there is at least one other input element in the form with any other autocomplete value. This will not work with password fields--those are handled very differently in Chrome. See https://code.google.com/p/chromium/issues/detail?id=468153 for more details.

Why autocomplete is not working in HTML?

This isn't a bug - autocomplete isn't supported by Chrome any more. It's a design decision by their developers and you should design for it rather than attempting to work around it.

Does autocomplete work off?

Setting autocomplete=”chrome-off” was the most promising for us. However, there is a limitation in that it will work for a maximum of 5 input fields; any more than that and Chrome will ignore it for the subsequent input fields.


2 Answers

Please provide ID to your input variable

<form method='post' action='myaction'>
 <input name='myname' type='email' id="myname" autocomplete='on' />
 <input type='submit' value='Submit!' onclick='transform_data();'/>
</form>

Then it should work, without id it wont work

like image 181
Sathish Murugesan Avatar answered Oct 13 '22 12:10

Sathish Murugesan


Chrome will only save the autocomplete information on submit. There are some workarounds detailed here: Trigger autocomplete without submitting a form

like image 24
Tom Avatar answered Oct 13 '22 13:10

Tom