[英]How do I ensure autocomplete works for a specific field?
How do browsers recognize if a particular field (like a username) should be prompted with autocompletes? 浏览器如何识别是否应该使用自动填充提示特定字段(如用户名)? Do they use some sort of regex to match the fields name
attribute? 他们是否使用某种正则表达式来匹配字段name
属性? Is there a standard I need to follow to ensure this? 是否有标准我需要遵循以确保这一点?
I ask this because on some sites the browser fails to suggest any historical data. 我问这个是因为在某些网站上浏览器无法提供任何历史数据。
Put simply, I am asking the exact opposite of what this person was trying to achieve: 简而言之,我问这个人想要达到的目的正好相反 :
How do you disable browser Autocomplete on web form field / input tag? 如何在Web表单字段/输入标记上禁用浏览器自动完成?
With HTML5: 使用HTML5:
<form action="demo_form.asp" method="get" autocomplete="on">
First name:<input type="text" name="fname" /><br />
E-mail: <input type="email" name="email" /><br />
<input type="submit" />
</form>
Source: http://www.w3schools.com/html5/att_form_autocomplete.asp 资料来源: http : //www.w3schools.com/html5/att_form_autocomplete.asp
In my experience it's based on matching the name or id attribute of the input tag. 根据我的经验,它基于匹配输入标记的name或id属性。 Which is why you generally find that username, email and name fields tend to autocomplete on a number of different websites. 这就是为什么您通常会发现用户名,电子邮件和名称字段倾向于在许多不同的网站上自动完成。
I think the matching has to be exact, not a regex or partial match on the field. 我认为匹配必须准确,而不是场上的正则表达式或部分匹配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.