简体   繁体   中英

Hide password manager autocomplete in form fields onfocus

I have a saved passwords in a chrome browser via password manager and I have this following input fields

<input type="text" placeholder="" formControlName="username" #log_name autocomplete="off">
<input type="password" placeholder="" formControlName="password" #pass autocomplete="off">

Everytime the page refresh the browser autofills the fields

在此处输入图片说明 在此处输入图片说明

what I did is a readonly and onfocus in input to disable the autofills

<input type="text" placeholder="" formControlName="username" #log_name autocomplete="off" 
readonly onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');}>

<input type="password" placeholder="" formControlName="password" #pass autocomplete="off" 
readonly onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');}>

now the autofills stops every refresh and it's good.

Problem

Is there a way I could hide the password manage autofill on focus of the field ( that black one )? 在此处输入图片说明

Try adding autocomplete to the form as shown below

<form name="loginForm" autocomplete="off">
<input type="text" placeholder="" formControlName="username" #log_name autocomplete="off" 
readonly onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');}>

<input type="password" placeholder="" formControlName="password" #pass autocomplete="off" 
readonly onfocus="if (this.hasAttribute('readonly')) {this.removeAttribute('readonly');}>
</form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM