3

I am trying to submit the form but It won't. It is auto-fill the input area after submitting once. However, after auto-fill the input it does not enable the submit button.

As it works on the rest of the browsers.

I have tried to add autocomplete off attribute in form tag as well as input tag but no luck.

<form autocomplete="off" ....````

Rahul Shinde
  • 168
  • 3
  • 12

3 Answers3

15

This works, but not the way that you think it does.

Officially it should be: autocomplete="off".

However many browsers bizarrely ignore this. Therefore it's best to just put some random string on the autocomplete section like:

autocomplete="autocomplete_off_randString"

Note that make sure the autocomplete value for each input is different (use JavaScript). Hence the random string at the end. Or else you may get suggestions from fields with the same autocomplete value.

Rokas
  • 199
  • 1
  • 8
  • 1
    Thanks @Rokas. Assigning each autocomplete attribute a unique value worked for me. Later, I discovered that my core problem was that I had two input elements that, even though they had unique element IDs, had the same element name. e.g.: ` ... `. Giving those input elements unique element names avoids the problem, and then I need not assign each autocomplete attribute a unique value. – Mike Finch Mar 10 '21 at 00:06
  • 1
    Whoops, I was half-right. Giving such input elements unique element names prevents those input elements from adding their values to the browser's cache of autocomplete text values. However, if the browser already has a cached autocomplete text value associated with such an input element, then auto completion can still happen. Therefore, the workaround suggested by @Rokas of assigning each autocomplete attribute a unique value still wins the day. – Mike Finch Mar 10 '21 at 00:19
  • https://karsep5.hashnode.dev/browser-autofill-for-web-developers this blog details how browsers handle autofill. – karsep5 Sep 02 '23 at 10:30
1

try to use autocomplete="new-password"as describe here

trxyzng
  • 11
  • 1
  • This is quite an old question that already has an approved answer. If documentation was updated, I suggest commenting on the approved answer with any updates that happened – Moudi Dec 19 '22 at 07:35
0

in edge worked for me autocomplete="false" readonly onfocus="this.removeAttribute('readonly');" / according to this https://stackoverflow.com/a/30344707/14913109

Hamza Qureshi
  • 172
  • 2
  • 20