【问题标题】:Chrome auto-fill are filling the wrong text inputsChrome 自动填充正在填充错误的文本输入
【发布时间】:2018-03-29 13:16:59
【问题描述】:

我正在编写一个 php 网站。我的问题确实在个人资料页面上。自动填充将我的电子邮件地址放在我输入街道地址的位置。这是我的意思的图像。

 <input type="text" name="txtstreetaddress" id="txtstreetaddress" placeholder="Street Address" tabindex="6" value="<?php echo $address ?>" style="font-family: 'Ubuntu';margin-top: -30px;font-size: 14px;height: 30px;width: 280px;" autocomplete="off" value="">

我也将表单设置为 autocomplete="off"

【问题讨论】:

  • 您是否确保 Chrome 个人资料中的自动填充信息正确无误?
  • 你正在设置value="&lt;?php echo $address ?&gt;",这可能是你的email-address

标签: php google-chrome autofill


【解决方案1】:

您必须使用autocomplete="false" 而不是“关闭”。

如果这仍然不起作用(我没想到),您可以通过在表单开头放置两个假字段来处理它,如下所示:

<input style="display:none" type="text" name="fakeusernameremembered"/>
<input style="display:none" type="password" name="fakepasswordremembered"/>

【讨论】:

  • 根据w3.org/wiki/HTML/Elements/input/textautocomplete = on/ off/ default
  • 双重检查:你是对的!对问题进行了进一步调查:这与自动完成无关。上图中发生的是chromes autofill,不受autocomplete="off"的影响。假字段似乎是目前唯一的解决方法。
  • 假字段不起作用,因为 Chrome 不会自动填充隐藏字段
  • 隐藏字段不再起作用。您需要隐藏它们而不实际隐藏它们,所以请执行以下操作:&lt;div style="overflow:hidden;width:0;height:0;"&gt;&lt;input type="text" name="username"&gt;&lt;/div&gt;
【解决方案2】:

在这里查看我的答案。 https://stackoverflow.com/a/62943913/12332625

为输入字段使用标签。我认为您的问题是您在一行上有 2 个输入字段。 &lt;label for="email"&gt;Your email&lt;/label&gt; 等应该可以解决您的问题。

像这样:

<label for="txtstreetaddress">Street Address:</label> <input type="text" name="txtstreetaddress" id="txtstreetaddress" placeholder="Street Address" tabindex="6" value="<?php echo $address ?>" style="font-family: 'Ubuntu';margin-top: -30px;font-size: 14px;height: 30px;width: 280px;" autocomplete="off" value="">

【讨论】:

    猜你喜欢
    • 2018-11-29
    • 2020-08-23
    • 1970-01-01
    • 1970-01-01
    • 2016-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-12
    相关资源
    最近更新 更多