13

I have a few text boxes on my page and find it very annoying the auto complete functionality. Is there any way to remove this from my site?

Zuul
  • 15,997
  • 6
  • 59
  • 87
Funky
  • 12,260
  • 35
  • 102
  • 158
  • 4
    FYI/ autocomplete is a browser preference and many people, including myself, believe these preferences should be left to the user's discretion. I believe that's why your question is being downvoted, not sure though. Users should explain their downvotes. – Matt K Aug 09 '11 at 15:37
  • @Matt K: For regular forms yes, but for password fields and some other cases, autocomplete messes up. This is a valid question, thought it should be clarified that it must be a crossbrowser fix. – Kalle H. Väravas Aug 22 '11 at 15:16
  • 1
    I think this is a perfectly reasonable question, and I can see a lot of good reasons to disable it. – JasonFruit May 10 '12 at 16:58
  • My use case, I have a form, I want the user to fill in with the aid of autocomplete if they wish, but I have a confirm email textbox. I want to ensure the email address entered is correct, so autocomplete is counter productive here. I want this to be a prompt for the user to check the email address potentially added by autocomplete. So this question is perfectly valid. – Liam Nov 20 '15 at 09:19

8 Answers8

30

Auto Complete

As of HTML 5, the auto complete is a form / input Attribute suported by all major browsers.

<form name="form1" id="form1" method="post" autocomplete="off" action="#">

Also, see here some more information about its usage:


Auto Capitalize and Auto Correct

If you are preparing an web application or any other Smartphone friendly web page, you might be interested in knowing how to: Disable Autocomplete, Autocapitalize, and Autocorrect.

<input autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />

<textarea autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
Community
  • 1
  • 1
Zuul
  • 15,997
  • 6
  • 59
  • 87
  • See more info at [w3schools.com/tags/att_input_autocomplete.asp](https://www.w3schools.com/tags/att_input_autocomplete.asp) – stomy Aug 24 '18 at 15:20
3

Add autocomplete="off" as form attribute and it applies to all fields inside the form.

Example : <form action="#" autocomplete="off">

Kathir
  • 1,145
  • 14
  • 24
3

This is how you can do this

autocomplete="new-text"

Add inside you input box or textarea

newbdeveloper
  • 332
  • 3
  • 11
2

autocomplete="off" can be added as a non-standard attribute to input fields. not sure which browsers besides IE support it though.

Matt K
  • 6,503
  • 3
  • 39
  • 57
  • autocomplete is in the [W3C spec](https://www.w3.org/wiki/HTML/Elements/input/text) so is very much a standard field. – Liam Nov 20 '15 at 09:16
  • It wasn't a standard in HTML4, which is the era this answer was written. [link to relevant SO question](http://stackoverflow.com/questions/582244/is-there-a-w3c-valid-way-to-disable-autocomplete-in-a-html-form) – Matt K Nov 20 '15 at 22:29
1

autocomplete="off" do not support instead of that use this 'autocomplete="new-password"'

Ragupathy
  • 129
  • 3
0

You can use jQuery to add the autocomplete attribute after the page loads. That's the best way I found to force Chrome to listen.

<script type="text/javascript" language="javascript">
    jQuery(function() {
        jQuery('#my_input').attr('autocomplete', 'off');
    });
</script>

<input type="text" name="my_input" id="my_input">
Vikrant
  • 5,290
  • 16
  • 48
  • 71
Jeff Sterup
  • 101
  • 4
0

autocomplete="off" works in Firefox, but it doesn't work in Chromium browsers on Ubuntu, so you need to check if the browser is a Chromium browser, and if it is use autocomplete="disabled", otherwise use autocomplete="off".

var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
$("#mobile").prop("autocomplete", is_chrome ? 'disabled' :  'off');
Donald Duck
  • 7,638
  • 19
  • 69
  • 90
Ramesh
  • 1,321
  • 11
  • 14
  • While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Donald Duck Dec 29 '20 at 11:22
  • autocomplete="off" attribute is working in firefox and chrome but it is not working in google chromium-browser in ubuntu so I have check if chromium and chrome browser then set disabled value in autocomplete attribute otherwise off value. – Ramesh Dec 30 '20 at 06:38
  • You were supposed to edit that into your answer, but it's OK, I did it for you. – Donald Duck Dec 30 '20 at 13:01
0

Simplest way: Remove name attribute, and add always a different string in autocomplete.

$(document).ready(function () {
    setTimeout(function () {
        var randomicAtomic = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
        $('input[type=text]').removeAttr('name');
        $('input[type=text]').attr('autocomplete', randomicAtomic);
    }, 1000);
})
Malik Zahid
  • 403
  • 3
  • 10