停止浏览器自动填写表单用户名和密码字段

Vij*_*der 15 html auto-populate struts1

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

现在,如果我导航到其他形式并且它包含其他一些东西的用户名和密码,那么我保存的那个是自动填充的.

我怎么能阻止这个?

小智 18

什么时候autocomplete=off不能阻止填写凭据,请使用以下 -

修复浏览器自动填充:readonly并在焦点上设置writeble(单击和选项卡).

 <input type="password" readonly onfocus="this.removeAttribute('readonly');" onblur="this.setAttribute('readonly','');"/>
Run Code Online (Sandbox Code Playgroud)


Ami*_*Das 7

请参考以下内容:
https : //www.chromium.org/developers/design-documents/create-amazing-password-formshttps://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>
Run Code Online (Sandbox Code Playgroud)


Ray*_*phy 6

对于Fire fox浏览器使用此:

<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="" />
Run Code Online (Sandbox Code Playgroud)

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


Ast*_*oCB 3

简单:有一个名为的HTML5属性autocomplete.

只需将其设置为off.

<input autocomplete="off"/>
Run Code Online (Sandbox Code Playgroud)

  • 这在Firefox中无法可靠地运行.这里有一些讨论http://stackoverflow.com/questions/6487970/disable-firefoxs-auto-fill (4认同)