如何阻止Chrome自动填充文本区域? [英] How to stop Chrome from autocompleting text areas?

查看:279
本文介绍了如何阻止Chrome自动填充文本区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理联系人表格中Chrome想要自动填写用户地址的部分文本区域.结果,用户提交了许多联系请求,并在注释字段中添加了他们的地址.除了可以利用的明显的潜在安全问题之外,我担心的是,从用户的角度来看,我们正在提供一个联系表单,其中没有用于键入消息的区域.而且从支持的角度来看,我们必须要求用户向他们发送带有他们实际问题的另一条消息.

I am dealing with a text area in part of a contact form that Chrome wants to autofill with the user's address. As a result many contact requests are submitted by users with their address in the comment field. Besides the obvious potential security issues that could be exploited, my concern is that from a user's standpoint we're providing a contact form without an area to type a message. And from a support standpoint, we're having to ask users to send us another message with their actual question.

HTML:

 <textarea id="element_10" class="validate[required] floatlabel js-auto-size multiple-lines" name="element_10" placeholder="Message*" rows="10" cols="60" required autocomplete="off"></textarea>

推荐答案

回答我自己的问题,因为我没有在Stack或任何Chrome浏览器文档中找到答案.

Answering my own question since I did not find the answer on Stack or in any Chrome browser docs.

在某些情况下,浏览器会不断建议自动补全值 即使autocomplete属性设置为off.这出乎意料 行为对于开发人员而言可能非常令人困惑.真正的窍门 强制no-autocompletion是将随机字符串分配给 属性,例如:

In some cases, the browser will keep suggesting autocompletion values even if the autocomplete attribute is set to off. This unexpected behavior can be quite puzzling for developers. The trick to really forcing the no-autocompletion is to assign a random string to the attribute, for example:

autocomplete="nope"

由于此随机值无效,浏览器将放弃.

Since this random value is not a valid one, the browser will give up.

https://developer.mozilla.org/zh-美国/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion

这篇关于如何阻止Chrome自动填充文本区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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