如何防止在Chrome中预填表单元素

如何防止在Chrome中预填表单元素

本文介绍了如何防止在Chrome中预填表单元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建Bootstrap表单,并且电子邮件和密码表单元素会使用来自某个其他网站或某个其他网站上早期表单登录的预填充数据显示。 Chrome浏览器会自动填充表单元素。



Bootstrap中是否有方法的HTML属性强制这些表单元素在页面加载时为null或为空? p>

2015-10-29 - 这是标记:

 < form autocomplete =offmethod =postrole =form> 
< div class =form-group>
< input name =formSubmittedtype =hiddenvalue =1>
< / div>
< div class =form-group>
< label for =用户名>用户名< / label>
< input autocomplete =offautofocus =autofocusclass =form-controlid =usernamename =usernamerequired type =text>
< / div>
< div class =form-group>
< label for =password>密码< / label>
< input autocomplete =offclass =form-controlid =passwordname =passwordrequired type =password>
< / div>
< button class =btn btn-defaulttype =submit>登入< / button>
< / form>


解决方案

使用属性。来自

另见:






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>
解决方案

Use the autocomplete="off" attribute on the <form> or <input>.

from MDN:

Also from MDN, see: How to Turn Off Form Autocompletion

Also see:

这篇关于如何防止在Chrome中预填表单元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 08:00