简体   繁体   English

如何在角度表单字段上禁用浏览器自动完成功能?

[英]How to disable browser autocomplete on angular form field?

I have a login page, i want to stop autocomplete and auto fills in my form page.我有一个登录页面,我想停止自动完成并自动填写我的表单页面。

By using autocomplete="off" auto fill Stopped.通过使用 autocomplete="off" 自动填充停止。 But autocomplete still load when i click the input fields (password or user name fields).但是当我单击输入字段(密码或用户名字段)时,自动完成仍然加载。 how to stop this autocomplete ?如何停止这个自动完成?

I tried the following methods, autocomplete="off", autocomplete="false", autocomplete="new-password" but still it came.我尝试了以下方法, autocomplete="off", autocomplete="false", autocomplete="new-password" 但它还是来了。

My sample code :我的示例代码:

<form #f="ngForm" autocomplete="off">
  <mat-form-field floatLabel="auto">
    <mat-label>User name</mat-label>
    <mat-icon matPrefix>person</mat-icon>
    <input matInput 
           tabindex="1" 
           #username="ngModel"
           [(ngModel)]="userName" 
           required 
           name="username"
           maxlength="100" 
           autocomplete="off" 
           role="presentation">
  </mat-form-field>
  <mat-form-field floatLabel="auto">
    <mat-label>Password</mat-label>
    <mat-icon matPrefix>lock</mat-icon>
    <input matInput 
           tabindex="2" 
           [(ngModel)]="password" 
           required 
           name="password" 
           #pass="ngModel" 
           type="password" 
           maxlength="100"
           autocomplete="new-password" 
           role="presentation">
  </mat-form-field>
</form>

Google chrome version: Version 76.0.3809.100 (Official Build) (64-bit)谷歌浏览器版本:76.0.3809.100 版(官方版本)(64 位)

在自动完成和随机名称上添加“anystring”以进行标记。

autocomplete="anyrandomstring" name="test"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 web 表单字段/输入标签上禁用浏览器自动完成功能? - How do you disable browser autocomplete on web form field / input tags? 使用角形和镀铬禁用自动填充/自动完成 - Disable autofill/autocomplete with angular form and chrome 如何在Windows 10移动版上禁用Web表单输入上的浏览器自动完成/建议? - How to disable browser Autocomplete/Suggestions on web form input on Windows 10 mobile? 如何使用EditorFor禁用输入字段的自动完成功能? - How to disable input field's autocomplete with EditorFor? 在 angular 中的垫子自动完成值 select 之后禁用输入字段? - Disable input field after select the value in mat autocomplete in angular? 如何在创建和编辑用户页面时禁用浏览器的登录名和密码自动完成功能? - How to disable login and password autocomplete by browser on creating and editing user pages? 如何在所有浏览器类型和版本中禁用密码自动完成或自动填充 - How to disable password autocomplete or autofill in all browser types & versions 如何在 React.js 中的 Input 元素上禁用浏览器自动完成 - How to disable browser autocomplete on Input element in React.js 禁用输入字段的自动完成/自动填充 - disable autocomplete / autofill for an input field 如何在密码字段(chrome和firefox)中禁用自动填充(自动完成) - How to disable auto fill (autocomplete) in password field (chrome and firefox)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM