如何阻止Chrome浏览器使我的网站的输入框变黄? [英] How do I stop Chrome from yellowing my site's input boxes?
问题描述
在表单提交和后验证的其他文本和视觉辅助工具中,我将我的输入框着色为红色,以表示需要注意的交互区域。
开Chrome(以及Google工具栏用户)的自动填充功能会将我的输入表单重新着色为黄色。以下是一个复杂的问题:我希望我的表单允许自动完成,因为它可以加速用户的登录速度。我将检查是否在触发错误时将autocomplete属性关闭,但它是一个复杂编码位以编程方式关闭页面上单个受影响输入的自动完成。简单来说,这将是一个令人头痛的问题。
因此,为了避免这个问题,有没有更简单的方法阻止Chrome重新着色输入盒?我尝试了!下面的重要建议,它没有效果。我还没有检查Google工具栏,看看!important属性是否适用。
据我所知,除了使用我知道在Firefox中,你可以使用属性autocomplete =off(自动完成属性)(它看起来可以工作)。
禁用自动完成功能。如果这在Chrome中有效(未测试),则可以在遇到错误时设置该属性。这可以用于单个元素
< input type =textname =nameautocomplete =off>
...以及整个表格
< form autocomplete =off...>
Among other text and visual aids on a form submission, post-validation, I'm coloring my input boxes red to signify the interactive area needing attention.
On Chrome (and for Google Toolbar users) the auto-fill feature re-colors my input forms yellow. Here's the complex issue: I want auto-complete allowed on my forms, as it speeds users logging in. I am going to check into the ability to turn the autocomplete attribute to off if/when there's an error triggered, but it is a complex bit of coding to programmatically turn off the auto-complete for the single affected input on a page. This, to put it simply, would be a major headache.
So to try to avoid that issue, is there any simpler method of stopping Chrome from re-coloring the input boxes?
[edit] I tried the !important suggestion below and it had no effect. I have not yet checked Google Toolbar to see if the !important attribute would work for that.
As far as I can tell, there isn't any means other than using the autocomplete attribute (which does appear to work).
I know in Firefox you can use the attribute autocomplete="off" to disable the autocomplete functionality. If this works in Chrome (haven't tested), you could set this attribute when an error is encountered.
This can be used for both a single element
<input type="text" name="name" autocomplete="off">
...as well as for an entire form
<form autocomplete="off" ...>
这篇关于如何阻止Chrome浏览器使我的网站的输入框变黄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!