Html 删除文本框上的自动完成
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6998677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove auto complete on text box
提问by Funky
I have a few text boxes on my page and find it very annoying the auto complete functionality. Is there any way to remove this from my site?
我的页面上有几个文本框,发现自动完成功能非常烦人。有什么办法可以从我的网站上删除它吗?
回答by Zuul
Auto Complete
自动完成
As of HTML 5, the auto complete is a form / input Attributesuported by all major browsers.
从 HTML 5 开始,自动完成是所有主要浏览器都支持的表单/输入属性。
<form name="form1" id="form1" method="post" autocomplete="off" action="#">
Also, see here some more information about its usage:
此外,请参阅此处有关其用法的更多信息:
Auto Capitalize and Auto Correct
自动大写和自动更正
If you are preparing an web application or any other Smartphone friendly web page, you might be interested in knowing how to: Disable Autocomplete, Autocapitalize, and Autocorrect.
如果您正在准备 Web 应用程序或任何其他智能手机友好的网页,您可能有兴趣了解如何:禁用自动完成、自动大写和自动更正。
<input autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
<textarea autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
回答by Matt K
autocomplete="off" can be added as a non-standard attribute to input fields. not sure which browsers besides IE support it though.
autocomplete="off" 可以作为非标准属性添加到输入字段。不知道除了 IE 之外还有哪些浏览器支持它。
回答by Kathir
Add autocomplete="off"
as form attribute and it applies to all fields inside the form.
添加autocomplete="off"
为表单属性,它适用于表单内的所有字段。
Example : <form action="#" autocomplete="off">
例子 : <form action="#" autocomplete="off">
回答by Ragupathy
autocomplete="off" do not support instead of that use this 'autocomplete="new-password"'
autocomplete="off" 不支持而不是使用这个 'autocomplete="new-password"'
回答by Jeff Sterup
You can use jQuery to add the autocomplete attribute after the page loads. That's the best way I found to force Chrome to listen.
您可以在页面加载后使用 jQuery 添加自动完成属性。这是我发现强制 Chrome 倾听的最佳方式。
<script type="text/javascript" language="javascript">
jQuery(function() {
jQuery('#my_input').attr('autocomplete', 'off');
});
</script>
<input type="text" name="my_input" id="my_input">