'autocomplete attribute not working

I would like to enable browser's autofill option by using the autocomplete attribute.

According to https://html.spec.whatwg.org/multipage/forms.html#autofill

<input autocomplete="given-name">
<input autocomplete="family-name">
<input autocomplete="address-line1">

The given-name and family-name should autofill the first and last name (western culture). I can get this to work if I add another field on the form for the address line. However, the form on my website does not have an address field, only first and last name.

This works, but I cannot use: https://jsfiddle.net/gt6m1bgj/5/

This does not work, and I need it to: https://jsfiddle.net/em8p92sb/1/

Any ideas?



Solution 1:[1]

Both your cases are working for me in Chrome 51 (OSX) And Safari 9.1.1

I had a quick look to see if I could find a chrome bug that had been resolved since your question, but quickly gave up on that :)

Another useful reference is: https://developers.google.com/web/updates/2015/06/checkout-faster-with-autofill?hl=en

Solution 2:[2]

Autocomplete attribute only works with on and off value, also it require name attribute in input.

<input autocomplete="on" name="name">

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ptim
Solution 2 sunny thakur