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?
-
4FYI/ 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
-
1I 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
9 Answers
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>
-
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
Add autocomplete="off"
as form attribute and it applies to all fields inside the form.
Example : <form action="#" autocomplete="off">

- 1,212
- 15
- 25
This is how you can do this
autocomplete="new-text"
Add inside you input box or textarea

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

- 6,620
- 3
- 38
- 60
-
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
autocomplete="off" do not support instead of that use this 'autocomplete="new-password"'

- 149
- 3
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">

- 4,920
- 17
- 48
- 72

- 101
- 4
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');

- 8,409
- 22
- 75
- 99

- 1,495
- 12
- 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
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);
})

- 593
- 5
- 13
use autocomplete = "off" in Html.BeginForm
@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new { @id = "myForm", @autocomplete = "off" }))
{
@Html.EditorFor(model => model.field, new { htmlAttributes = new { @class = "text-box form-control" } })
<input type="submit" value="Save" />
}

- 418
- 4
- 6