防止Chrome警告丢失的自动完成属性
在我的应用程序中,我有一个“更改密码”表格,该表格需要用户输入其当前密码和新密码(两次)。
输入当前密码的目的是安全措施,例如,如果用户远离桌子,则可以防止其他人更改密码并获得对帐户的控制。
因此,我绝对不希望该领域自动完成。但是,如果我不指定自动完成
属性,我会在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在自动完成属性中使用值 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.