首页 > 解决方案 > autocomplete=off 不适用于谷歌浏览器

问题描述

我知道这个问题之前已经回答过了,但无论我做什么,Chrome 总是会显示一个可能值的列表。

例如,对于这个字段:

<input type='text' id="sFechaCarga" name="sFechaCarga" class="font-12 form-control showCalRanges" autocomplete="off" />

谷歌认为这个字段是信用卡字段,显示信用卡的建议。

而对于这个其他领域:

<input type='text' id="sFechaEstado" name="sFechaEstado" class="font-12 form-control showCalRanges" autocomplete="off" />

谷歌认为它是一个状态值,显示对状态的建议。

正如有人在某些 SO 线程中建议的那样,我尝试使用 autocomplete="none" 或 autocomplete="fdsgsgsg" 。我什至使用过 autoComplete="off"。没有工作。

请问有什么帮助吗?

问候詹姆

标签: htmlautocomplete

解决方案


这不是一个完美的解决方案,但它现在正在工作。您应该添加只读属性,然后在焦点上将其删除。很简单,不是很漂亮(如果你需要大量输入,你可以尝试通过js添加它以最小化代码)。

<input type='text' id="sFechaCarga" name="sFechaCarga" class="font-12 form-control showCalRanges" readonly="readonly" onfocus="this.removeAttribute('readonly');" />

小提琴:http: //jsfiddle.net/0uzvqjfg/


推荐阅读