您如何在 Web 表单字段/输入标签上禁用浏览器自动完成功能?

2022-01-30 00:00:00 autocomplete forms browser html

如何在主要浏览器中为特定输入(或表单域)禁用自动完成功能?

How do you disable autocomplete in the major browsers for a specific input (or form field)?

推荐答案

Chrome的解决方案是在输入类型密码中添加autocomplete=new-password".请检查下面的示例.

The solution for Chrome is to add autocomplete="new-password" to the input type password. Please check the example below.

例子:

<form name="myForm"" method="post">
   <input name="user" type="text" />
   <input name="pass" type="password" autocomplete="new-password" />
   <input type="submit">
</form>

如果 Chrome 找到一个 type password 框,它总是自动完成数据,这足以指示该框 autocomplete = "new-password".

Chrome always autocomplete the data if it finds a box of type password, just enough to indicate for that box autocomplete = "new-password".

这对我很有效.

注意:使用 F12 确保您的更改生效.很多时候,浏览器将页面保存在缓存中,这给我一个不好的印象,它不起作用,但浏览器并没有真正带来变化.

Note: make sure with F12 that your changes take effect. Many times, browsers save the page in the cache, and this gave me a bad impression that it did not work, but the browser did not actually bring the changes.

相关文章