How to stop Chrome from autocompleting text areas?
Asked Answered
B

2

5

I am dealing with a text area in part of a contact form that Chrome wants to autofill with the user's address. As a result many contact requests are submitted by users with their address in the comment field. Besides the obvious potential security issues that could be exploited, my concern is that from a user's standpoint we're providing a contact form without an area to type a message. And from a support standpoint, we're having to ask users to send us another message with their actual question.

HTML:

 <textarea id="element_10" class="validate[required] floatlabel js-auto-size multiple-lines" name="element_10" placeholder="Message*" rows="10" cols="60" required autocomplete="off"></textarea>
Bowerbird answered 4/4, 2017 at 20:48 Comment(1)
Whoever finds this, here's an older SO question that seems to be continuously updated: Disabling Chrome AutofillOratorio
B
12

Answering my own question since I did not find the answer on Stack or in any Chrome browser docs.

In some cases, the browser will keep suggesting autocompletion values even if the autocomplete attribute is set to off. This unexpected behavior can be quite puzzling for developers. The trick to really forcing the no-autocompletion is to assign a random string to the attribute, for example:

autocomplete="nope"

Since this random value is not a valid one, the browser will give up.

https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion

Bowerbird answered 4/4, 2017 at 20:53 Comment(1)
Actually may not help in all cases. More details in Chrome bug discussion: bugs.chromium.org/p/chromium/issues/detail?id=914451#c99Floreneflorentia
I
0

I tried all the suggestions and nothing really worked consistently.

If I set one input to autocomplete="nope" it works.

If I set two or more it breaks them all.

If I set two to autocomplete="nope" and autocomplete="no" it works on those two but breaks again if I do anything to a 3rd.

My form only has 3 inputs. I just set email and phone and left name alone. That pretty much solves my problem.

I have some jquery validation that pretty much does not work with autocomplete and this client really does not want to be bothered with junk emails.

Also Chrome treats a one row textarea exactly the same as a input.

Impend answered 10/9, 2018 at 15:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.