16

在 Chrome 浏览器中,我已经保存了用户名和密码。

现在,如果我导航到其他表单并且它包含其他一些东西的用户名和密码,我保存的那个会自动填充到这里。

我怎样才能阻止这个?

4

6 回答 6

25

autocomplete=off不会阻止填写凭据时,请使用以下内容 -

修复浏览器自动填充:只读并将 writeble 设置为焦点(单击和选项卡)。

 <input type="password" readonly onfocus="this.removeAttribute('readonly');" onblur="this.setAttribute('readonly','');"/>
于 2016-05-11T05:45:07.007 回答
12

对于火狐浏览器使用这个:

<input type="text" name="prevent_autofill" id="prevent_autofill" value="" style="display:none;" />
<input type="password" name="password_fake" id="password_fake" value="" style="display:none;" />
<input type="password" name="password" id="password" value="" />

对于 Chrome 浏览器:使用autocomplete="new-password"

于 2017-05-24T04:47:28.660 回答
7

请参考以下内容:
https ://www.chromium.org/developers/design-documents/create-amazing-password-forms 和https://www.chromium.org/developers/design-documents/form-styles-那铬明白

尝试以下操作:

<form id="login" action="signup.php" method="post">
    <input type="text" autocomplete="username">
    <input type="password" autocomplete="new-password">
    <input type="password" autocomplete="new-password">
    <input type="submit" value="Sign Up!">
</form>
于 2019-04-03T06:07:52.063 回答
4

很简单:有一个 HTML5 属性叫做autocomplete.

只需将其设置为off.

<input autocomplete="off"/>
于 2014-07-02T17:24:40.507 回答
0
<textarea required="required" autocorrect="off" autocapitalize="off" name="username" class="form-control" placeholder="Your username"  rows="1" cols="20" wrap="off"></textarea>
<textarea required="required" autocorrect="off" autocapitalize="off" name="password" class="form-control password" placeholder="Your password"  rows="1" cols="20" wrap="off"></textarea>
@font-face {
  font-family: 'password';
  src: url('css/font/password.woff2') format('woff2'),
       url('css/font/password.woff') format('woff'),
       url('css/font/password.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

textarea.form-control {
  overflow:hidden;
  resize:none;
  height:34px;
}

textarea.form-control.password:valid {
  font-family: 'password';
}

笔记

  1. Textarea 防止自动填充
  2. wrap=off/overlow=hidden/rows=1 强制单行显示
  3. 所需的伪 css 使占位符有效
  4. 您可能需要一些“防止 eventKey=13 / 提交”的东西
  5. 在 fox/chrome/iOS 下工作正常

最后,它最终变成了一堆骇人听闻的黑客攻击(但它确实有效)

于 2021-11-17T22:47:16.403 回答
0

首先尝试将密码字段设置为

autocomplete="new-password"

上述解决方案应停止自动填写用户名和密码

注意:有时在用户名和密码上设置 autocomplete="off" 可能不起作用

于 2021-02-22T13:14:01.003 回答