3

I am building a Bootstrap form and the email and password form elements show with pre-populated data from some other or some earlier form login on a different site. The Chrome browser is auto-populating the form elements.

Is there an HTML attribute of method in Bootstrap to force these form elements to null or empty on page load?

2015-10-29 -- here's the markup:

      <form autocomplete="off" method="post" role="form">
        <div class="form-group">
          <input name="formSubmitted" type="hidden" value="1">
        </div>
        <div class="form-group">
          <label for="username">Username</label>
          <input autocomplete="off" autofocus="autofocus" class="form-control" id="username" name="username" required type="text">
        </div>
        <div class="form-group">
          <label for="password">Password</label>
          <input autocomplete="off" class="form-control" id="password" name="password" required type="password">
        </div>
        <button class="btn btn-default" type="submit">Login</button>
      </form>
4

2 回答 2

3

使用自动完成=“新密码”

很有魅力!

于 2018-06-29T13:55:58.113 回答
2

使用或autocomplete="off"上的属性。<form><input>

来自MDN

自动完成

该属性表示控件的值是否可以由浏览器自动补全。

off
用户每次使用都必须在此字段中显式输入一个值,或者文档提供自己的自动完成方法;浏览器不会自动完成输入。

on
允许浏览器根据用户在之前使用过程中输入的值自动完成值...

同样来自 MDN,请参阅:如何关闭表单自动完成

另见:

于 2015-10-29T18:48:20.423 回答