Search code examples
formscachingbrowserautofillclear-cache

Disable autofill on a web form through HTML or JavaScript?


Is there a way to disable autofill in Chrome and other browsers on form fields through HTML or JavaScript? I don't want the browser automatically filling in answers on the forms from previous users of the browser.

I know I can clear the cache, but I can't rely on repeatedly clearing the cache.


Solution

  • You can do it at the input level in HTML by adding autocomplete="off" to the input.

    http://css-tricks.com/snippets/html/autocomplete-off/

    You could also do it via JS such as:

    someForm.setAttribute( "autocomplete", "off" ); 
    someFormElm.setAttribute( "autocomplete", "off" );