Mobile Number Tracker
Trace Mobile Number Earn Money Online
© TechWelkin.com

Disable Autocomplete: How to Turn it Off in HTML Forms

HTML and JavaScript Tips at TechWelkin.
Samyak Lalit | April 10, 2015 (Last update: July 31, 2017)

Samyak Lalit is an Indian author and disability rights activist. He is the principal author and founder of projects like TechWelkin, WeCapable, Viklangta, Kavita Kosh among many others.

Autocomplete is a useful feature for the Internet surfers who go to a lot of websites and fill countless registration forms. Autocomplete helps these Internet users to quickly fill their details in the web forms. When a user fills in the first registration form in a fresh browser installation, the browsers (like Firefox, Google Chrome, Internet Explorer, Safari etc.) save the filled in details. When the user fills another similar web form, the browser will automatically fill the saved details in the form. Thus the browser saves time for the visitors.

But from the viewpoint of a web developer, autocomplete is sometimes a problem and the developer would want to turn off autocomplete. In such cases, the developer would want the visitor to fill in web form manually by typing everything. So, is it possible to disable autocomplete feature? The answer is, yes!

HTML and JavaScript Tips at TechWelkin.

HTML and JavaScript Tips at TechWelkin.

Most browsers honor the autocomplete=”off” attribute for the FORM tag of HTML. You can use this tag while coding your web form and browsers will disable autocomplete feature on that form.

But unfortunately different browsers have different standards. To be on the safer side, you should also disable autocomplete on the input tags as well. This approach has an advantage that you do not need to disable autocomplete for the entire form. Instead, you can be selective and turn off autocomplete only on certain input elements.

Here is an example:

<form autocomplete="off" name="myForm">
<input autocomplete="off" name="empName" type="text" />
<input name="empCode" type="text" />
</form>

Latest versions Firefox, Chrome and IE have a bit of different approach. These browsers circumvent autocomplete=”off” on password fields and prompts the user whether she wants to automatically enter the password or not. Such prompt comes only for the password fields. Google Chrome turns all the form fields light yellow color for which it has autocomplete information.

Browsers recognize form fields by their names and IDs. For example, let’s assume, a user is filling a form which has a field with name firstname. The browser will save the entered name against an input field called “firstname“. During the filling of another web form if the browser finds a field named “firstname” —it will simply input the value that the user had entered in previous form.

So, if you notice that a browser is not honoring autocomplete=”off” attribute, you may consider giving IDs and names of your fields as random text. This will ensure that the browser will not be able to recognize the fields and therefore won’t be able to fill in the data automatically.

How to disable Autocomplete when Autofill form extensions are installed

In addition to the built-in facility inside the browser —many people also use Firefox and Chrome extensions to autofill the forms. These extensions, obviously, do not honor autocomplete=”off” attribute and the developer will not be able to disable autocomplete if such extensions are installed.

Giving random names and IDs to input fields is the only way to beat autofill extensions.

I hope this information on how to disable and turn off autocomplete feature was useful for you. Should you have any questions in this regard, please feel free to comment and ask. I will try my best to assist you. Thank you for using TechWelkin!

© TechWelkin.com

19 responses to “Disable Autocomplete: How to Turn it Off in HTML Forms”

  1. Dave says:

    Disabling autocomplete for forward facing public sites is pretty much a nasty mistake. An almost certain way to turn a hefty percentage away from the idea of giving you whatever info you’re trying to collect, particularly as the autocomplete implementation becomes more and more widely understood and relied upon.

    While I can certainly understand there may be certain situations where it is troublesome, think long and hard before disabling it.

  2. G says:

    Autocomplete=”off” no longer works

    The easy way to do this is simply to make a password and email field and make them invisible

    This works because google chrome auto fills the first field it encounters with the password or email type or name.

    Hope this helps!

  3. krishna kant shukla says:

    Chrome does not honor autocomplete=”off”
    please suggest what to do?

    • Lalit Kumar says:

      There are several workaround but I would not recommend any of them. Hopefully, the Google Chrome Team take notice of this mistake and rectify it.

      • Dayle Hudson says:

        How long should it take for Google chrome team to notice when someone wants to get rid of auto complete? I and many others have asked. 2 years for me.

  4. Robert says:

    I’ve tested this and while it may have worked in the past it does not work now. For passwords, chrome targets the first field of type=”password” no matter what the name and id are. For creating new passwords for users, etc., it’s a major problem. There is a solution. Put this field right after the start of the form:

    Chrome will target this non-displayed field and leave your field alone. Tested it and it works.

  5. Steve says:

    Addendum: While the suggestions made in this article are certainly *possible*, you SHOULD NOT disable autocomplete unless there is a GOOD reason. And especially don’t get clever breaking autocomplete with randomized input names unless there is a DAMN GOOD reason.

    Your users generally should deserve the right to use the browser’s password saving feature, or a password vault extension of their choice. Don’t piss them off for no good reason. Disable autocomplete only when it is necessary and makes sense.

    • Lalit Kumar says:

      Hi Steve, I agree with what you said. Autocomplete feature should be disabled only when necessary. For example, if the input is for user name for a bank account, I would say autocomplete should be disabled. Giving randomized input names should be a big no because it might make you web app much more completed, and perhaps unpredictable too.

    • Dayle Hudson says:

      It mostly happens when I misspeak a word and back space to correct spelling. Too bad the corrected line isn’t the one that is sent. Good idea?
      My fields are filed out. I don’t know website.

    • Dayle Hudson says:

      Did this work for you? When I first got this I was looking up things like known mountains and other common knowledge. So that was good. When I started typing personal items that you would not know about I was upset when auto complete would come on. I remember thinking I would like to decide when I am finished typing. This is infringing on my rights to decide when I’m finished. It is like a rude child interrupting when your still talking.

  6. Cami says:

    Setting the autocomplete attribute to "off" does not disable Chrome autofill in more recent versions of Chrome. Instead you must set autocomplete on each input. you can set autocomplete to anything besides "on" or "off" and it will disable Chrome autofill

  7. Amit Kumar says:

    Hii Lalit

    Thank you so much for this great help, you save my lots of time. I read several articles and tried to Disable Autocomplete. Finally, I got a superb and short tutorial. Thanks for this helpful share!!

  8. kunal says:

    Hello Lalit bhai

    Nice topic you done great job in artical thanks for that

    Regards

    Kunal shah

Leave a Reply

Your email address will not be published. Required fields are marked *