当使用xhtml1-transitional。使用以下HTML收集一个信用卡号
<input type="text" id="cardNumber" name="cardNumber" autocomplete='off'/>
将在W3C验证器上标记一个警告:
没有“自动完成”属性。
是否有一种符合标准的方法来禁用浏览器自动完成表单中的敏感字段?
当使用xhtml1-transitional。使用以下HTML收集一个信用卡号
<input type="text" id="cardNumber" name="cardNumber" autocomplete='off'/>
将在W3C验证器上标记一个警告:
没有“自动完成”属性。
是否有一种符合标准的方法来禁用浏览器自动完成表单中的敏感字段?
当前回答
这个解决方案对我很管用:
$('form,input,select,textarea').attr("autocomplete", "nope");
如果你想在这个区域使用自动填充:在元素中添加autocomplete="false" 例:
<input id="search" name="search" type="text" placeholder="Name or Code" autcomplete="false">
其他回答
这个解决方案对我很管用:
$('form,input,select,textarea').attr("autocomplete", "nope");
如果你想在这个区域使用自动填充:在元素中添加autocomplete="false" 例:
<input id="search" name="search" type="text" placeholder="Name or Code" autcomplete="false">
Note that there's some confusion about location of the autocomplete attribute. It can be applied either to the whole FORM tag or to individual INPUT tags, and this wasn't really standardized before HTML5 (that explicitly allows both locations). Older docs most notably this Mozilla article only mentions FORM tag. At the same time some security scanners will only look for autocomplete in INPUT tag and complain if it's missing (even if it is in the parent FORM). A more detailed analysis of this mess is posted here: Confusion over AUTOCOMPLETE=OFF attributes in HTML forms.
不理想,但你可以改变id和文本框的名称,每次你渲染它-你必须跟踪它的服务器端,这样你就可以得到数据。
不确定这是否会起作用,这只是一个想法。
不,在Mozila Wiki上有一篇好文章。
我将继续使用无效属性。我认为这就是实用主义应该战胜认可的地方。
我建议捕捉所有4种类型的输入:
$('form,input,select,textarea').attr("autocomplete", "off");
参考:
http://www.w3.org/Submission/web-forms2/#the-autocomplete http://dev.w3.org/html5/markup/input.html