Disable autofill/autocomplete with angular form and chrome

disable chrome autofill programmatically
disable autocomplete chrome
autocomplete=off not working in angular 6
angular 2 disable autocomplete
vue-disable autocomplete
disable autofill html
disable autofill angular 6
autocomplete=off not working in angular 7

I have a simple form where I need disable autofill/autocomplete with angular form.

I have search on StackOverflow, but I didn´t find a solution.

I have used autocomplete="off" or autocomplete="false" but the autocomplete is never disabled.

Sometimes the autocomplete is disabled temporarily when I load a page. But, after some time after, when I reload the page the problem appears again.

//markup from image above

<input type="text" class="form-control input-lg ng-pristine ng-empty ng-invalid ng-invalid-required ng-touched" capitalize-full="" ng-model="user.ENDERECO" required="" placeholder="Digite seu endereço" autocomplete="off" name="street" style="opacity: 1; text-transform: uppercase;">

//markup sample

<form class="form form-horizontal" name="regForm" 
              autocomplete="false" novalidate role="form">
 <input  type="text" class="form-control input-lg"                           
  name="cpf" ng-model="user.CPF" placeholder="Digite seu CPF" 
   required autocomplete="false" >

In April 2018: Setting autocomplete="off" on the form itself worked for me (tested on Chrome). Setting this attribute on individual elements did not work.

How to turn off form autocompletion, This article explains how a website can disable autocomplete for form fields. If a site sets autocomplete="off" for a <form> , and the form includes username This is the behavior in Firefox (since version 38), Google Chrome  To disable or enable autocomplete of text in forms, use the autocomplete attribute of <input> and <form> elements. This attribute contains two values: This attribute contains two values: on (specifies that autocomplete is enabled, this is the default value)

The autocomplete="off" is effectively respected by Chrome, but what you're experiencing is the Chrome autofill functionality that takes over, ignoring autocomplete="off": https://developers.google.com/web/updates/2015/06/checkout-faster-with-autofill.

In the past, many developers would add autocomplete="off" to their form fields to prevent the browser from performing any kind of autocomplete functionality. While Chrome will still respect this tag for autocomplete data, it will not respect it for autofill data.

I did some test and from what I see here Chrome igonores the autocomplete="off" when it can map the fieldname to one of it's autofill properties. This will work <input type="text" name="somethingAutofillDoesntKnow" autocomplete="off" />, but for this fieldName Autofill will show up <input type="text" name="firstName" autocomplete="off" />.

One workaround is to put an unknown value in the autocomplete, e.g. autocomplete="doNotAutoComplete". When testing this it worked for me most of the time, but for some reason didn't work anymore afterwards.

My advise is not to fight against it and use it's potential by properly using the autocomplete attribute as explained here: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill

Disable HTML form input autocomplete and autofill · GitHub, Adding autocomplete="off" to a text input worked for me in Chrome. work on Version Chrome Version 71.0.3578.98 (Form was created in angular@7 App)  At the bottom of the AutoComplete Settings window, click Delete AutoComplete History. Check Form Data and Passwords. Click Delete. Click OK in the AutoComplete Settings Window. Click OK in the Internet Options Window. Google Chrome. In Google Chrome, you will want to not only turn off autofill data, but also clear it. Instructions are listed below. Turning Off Autofill in Chrome. Click the Chrome menu icon. (Three lines at top right of screen.) Click on Settings. At the bottom of the page

Try <input autocomplete="off" type="search"> it worked for me

How to turn off password and email/username autocomplete. · GitHub, except for username/email/password fields. -->. <form autocomplete="off">. <!-- fake fields are a workaround for chrome/opera autofill getting the wrong fields -->. Angular 2 and browser autofill. Autofill and autocomplete? And angular works with them differently? How do you disable browser Autocomplete on web form field

In Angular, this directive worked for me. Using the autocomplete="off" should have solved the issue, but it seems as though the DOM rendering sequence prevents that unless you use a timeout.

Additionally, if you use something like mat-form-field and autocomplete is generated based on the unique names, you can add a Zero-width non-joiner anywhere after the first character and before the last character.

import { Directive, ElementRef, OnInit, Renderer2, AfterViewInit } from '@angular/core'

  selector: '[NoAutocomplete]',
export class NoAutocompleteDirective implements AfterViewInit {
  constructor(private renderer: Renderer2, private _el: ElementRef) {}
  ngAfterViewInit() {
    setTimeout(() => {
      const inputs = Array.prototype.slice.call(this._el.nativeElement.querySelectorAll('input'))
      inputs.map((e, i) => {
        this.renderer.setAttribute(e, 'autocomplete', 'off')
      // If you're using mat-form-field
      const labels = Array.prototype.slice.call(
      labels.map((l, i) => {
        l.innerHTML = l.innerHTML.replace(
          l.textContent.substring(0, 1) + '&zwnj;' + l.textContent.substring(1)
    }, 0)

Disabling autofill in Chrome, MDN has an article showing “How to turn off form autocompletion”. The solution is using the autocomplete attribute with an off value. This doesn't  If you generate unique random autocomplete names you disable auto complete. If your users have visited bad forms their autofill information may be corrupt. Having them manually go in and fix their autofill information in Chrome may be a necessary action from them to take.

Simply put autocomplete="new-feildName" on html control

Example :

 <input class="signup-input-field-01" autocomplete="new-phone" 
            formControlName="phone" name="phone" type="text">

Turn Off Autocomplete for Input, Like a CAPTCHA input, one-time use codes, or for when you have built your own auto-suggest/auto-complete feature and need to turn off the browser default. @kcaporaso I think that Chrome must have finally relented on their contrarian interpretation of the standard. I'm encountering this issue for the first time, and autocomplete="off" on the form tag seems to work, even in spite of thousands of complaints scattered across every help site on the internet claiming to the contrary.

How to disable Chrome autofill (autocomplete) in TextBox in Angular 5, Above archived ticket addressed the old fix for disabling the chrome autofill via the form tag. Currently to my knowledge the old fixes have been  It is important to know that if you turn off autocomplete, you are breaking the rule 1.3.5: Identify Input Purpose in WCAG 2.1. If you are making a website that should follow WCAG, you should use autocomplete with autofill. Disabling autocompletion. To disable autocompletion in forms, you can set the autocomplete attribute to "off": autocomplete="off"

How to Disable Browser Autocomplete and Autofill on HTML Form , Use autocomplete="off" to specify that autocomplete is disabled. To disable or enable autocomplete of text in forms, use the autocomplete attribute of In this way behave Firefox (since version 38), and Google Chrome (since version 34). How To JavaScript · How To NodeJs · How To Linux · How To AngularJs · How To  I created a mixin that solves the issue on Chrome. Add it to the component that creates your text fields, selects, combos, autocompletes, etc. /* This Vue mixin will prevent Chrome autocomplete on text fields by setting autocomplete='new-password' where autocomplete='off' for every input that exists inside a component.

HTML - How to disable autocomplete of an input text, The problem, however, is that the browsers now do not respect the autocomplete​="false" or autocomplete="off" . so, when user click on the text  Fixing autocomplete (autofill) on AngularJS form submit. Posted by zeke in AngularJS | 14 comments. Many browsers support autocomplete but do not trigger “change” events on inputs when the user initiates autocomplete.