防止Chrome警告丢失的自动完成属性

发布于 2025-02-12 02:04:24 字数 737 浏览 0 评论 0原文

在我的应用程序中,我有一个“更改密码”表格,该表格需要用户输入其当前密码和新密码(两次)。

输入当前密码的目的是安全措施,例如,如果用户远离桌子,则可以防止其他人更改密码并获得对帐户的控制。

因此,我绝对不希望该领域自动完成。但是,如果我不指定自动完成属性,我会在Chrome的Dev Console中获取以下警告

[dom]输入元素应具有自动完整属性(建议:“ current-password”):(更多信息: https://www.chromium.org/developers/design-documents/create-amazing-password-forms/ )密码“ type =“ password”>

如果我添加一个属性autoComplete =“ current-password”警告不再出现,但是该字段会自动填充用户的当前密码,这打败了该字段的目的。

我如何防止在镀铬控制台上发出警告的情况下自动填充该领域?

In my app I have a "change password" form which requires a user to enter their current password and their new password (twice).

The purpose of entering the current password is a security measure, e.g. if a user steps away from their desk, it prevents someone else from changing their password and gaining control of their account.

For this reason, I absolutely do not want this field to be autocompleted. However, if I don't specify an autocomplete attribute, I get the following warning in Chrome's dev console

[DOM] Input elements should have autocomplete attributes (suggested: "current-password"): (More info: https://www.chromium.org/developers/design-documents/create-amazing-password-forms/) <input id=​"current-password" type=​"password">​

If I add an attribute autocomplete="current-password" the warning no longer appears, but the field is filled automatically with the user's current password, which defeats the very purpose of this field.

How can I prevent this field from being filled automatically without getting a warning in the Chrome console?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抽个烟儿 2025-02-19 02:04:24

您可以在自动完成属性中使用值 off
例如:autoComplete =“ off”

MDN Web Docs

You could use the value off in the autocomplete attribute.
For example: autocomplete="off"

Read more about it on MDN Web Docs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文