この質問はかなり古いですが、2017 年の最新の回答があります。
オートコンプリートをトリガーする方法に関する完全なドキュメントが作成されました。
これは、オートコンプリートを有効にするための公式の現在の WHATWG HTML 標準へのリンクです。
次の回答は、ここからの私の元の回答からのものです: https://stackoverflow.com/a/41965106/1696153
Google は、モバイル デバイスに適した Web アプリケーションを開発するための非常に優れたガイドを作成しました。自動入力を簡単に使用できるように、フォームの入力に名前を付ける方法に関するセクションがあります。モバイル向けに書かれていますが、これはデスクトップとモバイルの両方に当てはまります。
HTML フォームでオートコンプリートを有効にする方法
オートコンプリートを有効にする方法の重要なポイントを次に示します。
<input>
タグに名前を付ける方法
In order to trigger autocomplete, make sure you correctly name the name
and autocomplete
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
- Use any of these for
name
: name fname mname lname
- Use any of these for
autocomplete
:
name
(for full name)
given-name
(for first name)
additional-name
(for middle name)
family-name
(for last name)
- Example:
<input type="text" name="fname" autocomplete="given-name">
- Email
- Use any of these for
name
: email
- Use any of these for
autocomplete
: email
- Example:
<input type="text" name="email" autocomplete="email">
- Address
- Use any of these for
name
: address city region province state zip zip2 postal country
- Use any of these for
autocomplete
:
- For one address input:
- For two address inputs:
address-line1
address-line2
address-level1
(state or province)
address-level2
(city)
postal-code
(zip code)
country
- Phone
- Use any of these for
name
: phone mobile country-code area-code exchange suffix ext
- Use any of these for
autocomplete
: tel
- Credit Card
- Use any of these for
name
: ccname cardnumber cvc ccmonth ccyear exp-date card-type
- Use any of these for
autocomplete
:
cc-name
cc-number
cc-csc
cc-exp-month
cc-exp-year
cc-exp
cc-type
- Usernames
- Use any of these for
name
: username
- Use any of these for
autocomplete
: username
- Passwords
- Use any of these for
name
: password
- Use any of these for
autocomplete
:
current-password
(for sign-in forms)
new-password
(for sign-up and password-change forms)
Resources