浏览器默认填充是前端很常见的一个问题,无论是注册页还是数据表单页,只要包含地址或是密码框就会调起浏览器的自动填充行为,其实autocomplete
属性就可以解决大部分这些问题,只要在input
标签里写上这个属性对应的功能名称即可,对应关系如下:
off: 用户必须手动填值,或者该页面提供了自己的自动补全方法。浏览器不对此字段自动填充。
on: 浏览器可以根据用户先前的填表情况对此字段自动填值。
name: 完整的姓名
honorific-prefix: Prefix or title (e.g. "Mr.", "Ms.", "Dr.", "Mlle")
given-name :名
additional-name
family-name:姓
honorific-suffix: Suffix (e.g. "Jr.", "B.Sc.", "MBASW", "II")
nickname
email
username
new-password: 新密码(如创建帐号或更改密码时使用)
current-password
organization-title: Job title (e.g. "Software Engineer", "Senior Vice President", "Deputy Managing Director")
organization
street-address
address-line1, address-line2, address-line3, address-level4, address-level3, address-level2, address-level1
country
country-name
postal-code
cc-name: Full name as given on the payment instrument
cc-given-name
cc-additional-name
cc-family-name
cc-number: Code identifying the payment instrument (e.g. the credit card number)
cc-exp: Expiration date of the payment instrument
cc-exp-month
cc-exp-year
cc-csc: Security code for the payment instrument
cc-type: Type of payment instrument (e.g. Visa)
transaction-currency
transaction-amount
language: Preferred language; Valid BCP 47 language tag
bday
bday-day
bday-month
bday-year
sex: Gender identity (e.g. Female, Fa'afafine); Free-form text, no newlines
tel
url: Home page or other Web page corresponding to the company, person, address, or contact information in the other fields associated with this field
photo: Photograph, icon, or other image corresponding to the company, person, address, or contact information in the other fields associated with this field
如是密码类型input
将autocomplete
设置为new-password
…