什么是正确的方式来阻止表单输入框自动完成? [英] What is the correct way to stop form input boxes auto-completing?

查看:415
本文介绍了什么是正确的方式来阻止表单输入框自动完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,其中包括attatched到&LT jQuery的日期选择器,输入> 的形式。我当时的问题是,由于输入的是一个文本框,大多数主流浏览器尝试自动完成的项目对于用户来说,这看起来很无聊的在日期选择器:

I have a form which includes a JQUERY datepicker attatched to an <input> on the form. My problem at the moment is that since the input is a text-box, most major browsers attempt to auto-complete entries for the user, which looks very silly over the datepicker:

浏览互联网,我发现,早在IE-5的日子里,微软有一个名为自动完成输入标签,它可以禁用它的属性。但是,这是在很久以前,那就是IE浏览器。在检查W3Schools的透露,HTML5的的包括输入标签的自动完成的属性(是的,我也同样感到惊讶,微软支持HTML-5,早在1999年...)。然而,我们的网站是不是对HTML5,所以我不能依赖于使用标记,并假设它会奏效。考虑到这些,那么,人们如何禁用自动完成对HTML4一个输入框?预计浏览器是Chrome浏览器(最新的),火狐3.6,火狐2.0和 - 上帝帮助我们 - 也许IE6(虽然我们已经警告过大家,我们不看好什么,如果他们使用IE6将实际工作;!))

Browsing the internet, I discovered that way back in the days of IE-5, Microsoft had an attribute for input tags called "autocomplete", which could disable it. However, that was way back then, and that was IE. Checking on W3Schools revealed that HTML5 also includes an "autocomplete" attribute for input tags (yes, I was equally surprised that Microsoft was supporting HTML-5 way back in 1999...). However, our website is not on HTML5 yet, so I cannot rely on using the tag and assuming it will work. Taking these into consideration, how then does one disable auto-complete for a single input box in HTML4? Expected browsers are Chrome (latest), Firefox 3.6, Firefox 2.0 and - god help us - perhaps IE6 (although we have warned everyone that we aren't promising anything will actually work if they use IE6! ;) )

(顺便说一句,对任何人担心在那里,我知道,这是试图改变用户的个人浏览器设置,这是通常做一个顽皮的事情。然而,在这种情况下,我认为这是合理的,特别是考虑到90我的用户的%的不知道什么是自动完成的,或者它甚至可以被关闭......)

(By the way, for anybody worrying out there, I know that this is attempting to change a user's personal browser settings, which is a naughty thing to do normally. However, in this case I believe it's justified, especially considering 90% of my users won't know what auto-complete is or that it even can be turned off...)

推荐答案

您可以这样做:

<input autocomplete="off">

您还可以在表单级别点它

You can also dot it at the form level

<form id="stuff" autocomplete="off" method="post" >

它的工作原理。

这篇关于什么是正确的方式来阻止表单输入框自动完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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