I would like to know if there is some kind of special markup to enable the Chrome autofill feature for a specific form. I only found questions about how to disable it, but I would like to know if I can add some kind of markup to the html code in order to tell the browser "this is the input for the address" or "this is the ZIP code field" to correctly fill it in (assumed the user activated this feature).
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
You need to name the elements appropriately so that the browser will autofill them.
Here's the IETF spec for this:
http://www.ietf.org/rfc/rfc3106.txt1
In my case,
$('#EmailAddress').attr('autocomplete', 'off');
is not worked. But following works on chrome Version 67 by jQuery.From my testing, the
x-autocomplete
tag does nothing. Instead useautocomplete
tags on your input tags, and set their values according to the HTML spec here http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#autofill-field .Example:
The parent form tag needs autocomplete="on" and method="POST".
I just played arround with the spec and got a nice working example - including a few more fields.
JSBIN
It contains 2 separate address areas and also differen address-types. Tested it also on iOS 8.1.0 and it seems that it always fill all fields at once, while desktop chrome autofill address by address.
Here is the new list of Google Autofill "names". There are all the supported names in any allowed language.
autofill_regex_constants.cc
This question is pretty old but I have an updated answer for 2017!
Here's a link to the WHATWG documentation for enabling autocomplete.
Google wrote a pretty nice guide for developing web applications that are friendly for mobile devices. They have a section on how to name the inputs on forms to easily use auto-fill. Eventhough it's written for mobile, this applies for both desktop and mobile!
How to Enable AutoComplete on your HTML forms
Here are some key points on how to enable autocomplete:
<label>
for all your<input>
fieldsautocomplete
attribute to your<input>
tags and fill it in using this guide.name
andautocomplete
attributes correctly for all<input>
tagsExample:
How to name your
<input>
tagsIn order to trigger autocomplete, make sure you correctly name the
name
andautocomplete
attributes in your<input>
tags. This will automatically allow for autocomplete on forms. Make sure also to have a<label>
! This information can also be found here.Here's how to name your inputs:
name
:name fname mname lname
autocomplete
:name
(for full name)given-name
(for first name)additional-name
(for middle name)family-name
(for last name)<input type="text" name="fname" autocomplete="given-name">
name
:email
autocomplete
:email
<input type="text" name="email" autocomplete="email">
name
:address city region province state zip zip2 postal country
autocomplete
:street-address
address-line1
address-line2
address-level1
(state or province)address-level2
(city)postal-code
(zip code)country
name
:phone mobile country-code area-code exchange suffix ext
autocomplete
:tel
name
:ccname cardnumber cvc ccmonth ccyear exp-date card-type
autocomplete
:cc-name
cc-number
cc-csc
cc-exp-month
cc-exp-year
cc-exp
cc-type
name
:username
autocomplete
:username
name
:password
autocomplete
:current-password
(for sign-in forms)new-password
(for sign-up and password-change forms)Resources