0

i want to disable autofill and autocomplete google chrome option i tried variant solution like :

  • set *autocomplete="off" OR autocomplete="nope"
  • set input type="search"
  • an unknown value in the autocomplete like autocomplete="someThingUnknown"

is there any solution ?

Saad
  • 130
  • 2
  • 11

1 Answers1

0

I found a solution :

1 - set input type="text" to readonly :

<input type="text" [readonly]="inputText" />

2 - set input type password to type text and change css to looks like a password input :

html :

<input type="text" [readonly]="inputPassword" class="pw-field"/>

css :

.pw-field{
        -webkit-text-security: disc;
 }

3- Add a focusEvent to both inputs:

html:

<input type="text" [readonly]="inputText" (focus)='focusFunction("text")' />

<input type="text" [readonly]="inputPassword" class="pw-field" (focus)='focusFunction("pw")' />

ts:

focusFunction(type){
  if(type == "text"){
        this.inputText = false;
        this.inputPassword = true;
    }else if(type == "pw"){
        this.inputText = false;
        this.inputPassword = true;
    }
}
Saad
  • 130
  • 2
  • 11