在 Chrome 中禁用表单自动填充而不禁用自动完成 [英] Disable form autofill in Chrome without disabling autocomplete

查看:35
本文介绍了在 Chrome 中禁用表单自动填充而不禁用自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何在某些 上禁用 Chrome 的自动填充功能,以防止它们在页面加载时自动填充?

How can we disable Chrome's autofill feature on certain <input>s to prevent them from being automatically populated when the page loads?

同时我需要保持自动完成功能,这样用户仍然可以通过点击输入或输入来查看建议列表.可以这样做吗?

At the same time I need to keep autocomplete enabled, so the user can still see the list of suggestions by clicking on the input or typing in it. Can this be done?

如果您觉得有必要或者您觉得这会让您的解决方案更简单,请随意使用普通的 Javascript 或 jQuery.

Feel free to use plain Javascript or jQuery if you feel it is necessary or you feel like it would make your solution simpler.

推荐答案

这就是你想要的魔法:

    autocomplete="new-password"

Chrome 故意忽略 autocomplete="off"autocomplete="false".但是,他们将 new-password 作为特殊子句放入,以阻止自动填充新密码表单.

Chrome intentionally ignores autocomplete="off" and autocomplete="false". However, they put new-password in as a special clause to stop new password forms from being auto-filled.

我在密码输入中输入了上面一行,现在我可以编辑表单中的其他字段,并且密码不会自动填充.

I put the above line in my password input, and now I can edit other fields in my form and the password is not auto-filled.

这篇关于在 Chrome 中禁用表单自动填充而不禁用自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆