【问题标题】:auto complete attibute not working in HTML自动完成属性在 HTML 中不起作用
【发布时间】:2019-02-09 14:35:52
【问题描述】:

我有带有电子邮件地址的输入框。它不应该是自动完成的,但即使在输入框中添加了 autocomplete="off" 之后也是如此。它显示自动完成值。

【问题讨论】:

标签: html


【解决方案1】:

它可能在chrome中找到...但是你可以尝试

在表单标签中添加autocomplete="off" autocomplete="false" autofill="off"

然后在表单打开后添加以下代码...

<input type="text" name="usernamefake" style="display:none;"> 
<input type="password" name="fakepassword" style="display:none;"> 

<!-- from here now your all input fields...below-->

如果您的问题无法通过上述解决方案得到解决,您可以在您的实际电子邮件输入字段上方再添加一个隐藏的假输入字段并试一试...

更新:

你可以试试

<input type="text" name="email" readonly  onfocus="if (this.hasAttribute('readonly')) {
 this.removeAttribute('readonly');
 this.blur();    this.focus();  }" />

this.blur(); this.focus(); 用于移动屏幕在删除只读属性后显示键盘..by js

示例代码:

div{
  padding:10px;
  margin:20px;
}
input {
  padding:5px;
  margin:5px;
}
<div>
<form autocomplete="off">
  <label for="email">E-Mail</label>
  <input id="email" readonly type="email" onfocus="if (this.hasAttribute('readonly')) { this.removeAttribute('readonly');
     this.blur();    this.focus();  }" />
  <br/>
  <label for="pw">Password</label>
  <input id="pw" readonly type="password" onfocus="if (this.hasAttribute('readonly')) { this.removeAttribute('readonly');
    this.blur();    this.focus();  }" />
  <br/>
  <input type="submit" value="Go!" />
</form>

</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-23
    • 1970-01-01
    • 2015-11-09
    • 1970-01-01
    相关资源
    最近更新 更多