[英]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.