25

I have built a textbox dropdown AngularJS component which works great in Chrome, Firefox, Safari and Internet Explorer.

A feature of this component is that you type in a string, and then can use the up/down arrow keys to scroll through suggestions.

In Microsoft Edge, as soon as you hit the down arrow, the following text is added to the input box:

briefly explain your changes (corrected spelling, fixed grammar, improved formatting)

Is there anything I can do client side to stop this from happening?

<form>
    <input type="text" />    
</form>

To demonstrate this, run the above snipper, type something into the textbox and hit the down arrow twice on Edge. I want this to not happen, as it is breaking my autocomplete!

Thanks

JMK
  • 27,273
  • 52
  • 163
  • 280
  • Are you using an input? If not, what type of element are you using? Are you trying to fix this issue whatever way possible or with an Angular.js solution? – rockmandew Sep 25 '15 at 15:47
  • A bog standard text input, to build the component, can post some code if you wish? – JMK Sep 25 '15 at 15:48
  • Might as well, not sure what a "bog" standard text input is to be completely honest. I'm assuming that was a typo and you're just talking about a regular text input. Please post the code and I will follow up. I'm going to assume, it's a simple "autocomplete" setting solution. – rockmandew Sep 25 '15 at 15:52
  • Apologies, it's an irish colloquialism, posted an example – JMK Sep 25 '15 at 15:53
  • its not a problem at all, I just wanted to clarify to make sure I was giving you accurate information. Did that solution work? If so, could you please accept the answer so the topic is closed? – rockmandew Sep 25 '15 at 16:04
  • Using the `aria-autocomplete` attribute, as suggested in answer https://stackoverflow.com/a/73691203/1694840 , disables the autocomplete for me. – Benjamin Wolff Sep 21 '22 at 10:00

12 Answers12

32

If I understand correctly, you are having an issue with the autocomplete feature. Simple add "autocomplete='off'" to your input and that should disable the feature.

<input type="text" autocomplete="off"/>
rockmandew
  • 820
  • 13
  • 22
  • This won't work on any modern browser. Try using decoy fields. http://stackoverflow.com/a/2555771/317908 – Michael Kuhinica Aug 17 '16 at 03:35
  • In Edge, if you backspace and delete the contents of the input, Edge will then display the autocomplete box. So while this attribute helps, it does not solve the problem. – Brain2000 Nov 28 '17 at 20:44
  • 9
    I just found that Microsoft disabled the "autocomplete=off" attribute. What a terrible decision. https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9847360/ – Brain2000 Nov 28 '17 at 20:56
  • @Brain2000 - Is this for all Microsoft browsers or just below edge? – rockmandew Nov 29 '17 at 15:40
  • 1
    @rockmandew Just Edge. IE 11 still works. I found the suppression works on Edge to some extent, as the autocomplete can still appear if you tab into an input and press backspace to remove the contents. – Brain2000 Dec 16 '17 at 16:42
  • @Brain2000 Chrome ignores autocomplete=off as well. https://stackoverflow.com/questions/12374442/chrome-browser-ignoring-autocomplete-off – Mike Mar 20 '18 at 19:50
26

Unfortunately, none of the above suggestions worked for me in latest Edge. However, this solution does:

<input type="text" autocomplete="off" list="autocompleteOff" 
    id="fieldId" name="fieldname" placeholder="Placeholder here" />

This forces Edge to find a data lookup list called autocompleteOff which doesn't exist. Works a treat for me.

Added advantage is that it's pure HTML, no CSS or JS required.

2021 update:

Another solution which works very well for me is to add the readonly attribute to the field and then remove the tag using JQuery after a short delay of a few ms. The readonly attributes causes Edge (and others) to ignore the field.

SimonGoldstone
  • 5,096
  • 3
  • 27
  • 38
23

For anyone experiencing autofill ignoring the autocomplete="off" on Edge 105+, you can use aria-autocomplete="none" alongside, which will prevent autofill from showing up (Tested in macOS 12.5 but should work in other platforms)

  • It works for me on Edge Version 105.0.1343.42, how do you know this way? – ravin.wang Sep 19 '22 at 13:21
  • 1
    I read a couple of blog posts/chrome issues on auto completion vs autofill and someone mentioned the aria-autocomplete attribute, for which I read the doc and tested. Sure enough, Edge doesn't ignore such attribute when dealing with autofill – Miguel Sánchez Villafán Sep 20 '22 at 01:18
  • 3
    Adding the `aria-autocomplete` solved it for me on Windows 10 running Edge Version 105.0.1343.42. This answer should probably be promoted to the accepted solution. – Benjamin Wolff Sep 21 '22 at 09:59
  • 2
    I was going crazy because all of my old workarounds stopped working and none of the other suggestions I could find worked. aria-autocomplete worked for me in Windows 10, Edge Version 106.0.1370.37 – Erin Halbmaier Nov 02 '22 at 16:31
  • autocomplete="off" + aria-autocomplete="none" no longer works for us on Edge version 112.0.1722.34 – OvalOlive Apr 19 '23 at 08:16
  • 1
    Working perfectly on Edge Version 114.0.1823.67 (Official build) (64-bit), Windows 11 – gregoryp Jul 12 '23 at 03:18
8

From Mozilla: You can set the autocomplete on the actual form tag <form autocomplete='off' ... >...</form> which will work for the entire form, or on individual <input type='text' /> tags.

In my experience on IE 11 and Edge putting it on the form works but individual tags does not work. I tried testing on Chrome but the fields were already not autocompleting.

Please read the full Article for more detailed information.

NOTE

Most browsers disregard this for login fields.

Maximilian Ast
  • 3,369
  • 12
  • 36
  • 47
4

if you want to remove autocomplete at the input in chrome when you use autocomplete="off" also you must remove id, if you don't remove id on your input, autocomplete will not work!

simple example:

<input type="text" autocomplete="off" list="autocompleteOff" 
     name="fieldname" placeholder="Placeholder here" />

you can handle your input with name ;) , that work for me fine.

Aras
  • 1,599
  • 15
  • 25
3
<input type="text" autocomplete="new-password" />

If you are defining a user management page where a user can specify a new password for another person, and therefore you want to prevent autofilling of password fields, you can use autocomplete="new-password"

MDN reference

It works also for non-password fields.

Amr Eid
  • 39
  • 2
2

if you need it app/site-wide you can use jquery:

$('input').attr('autocomplete','off');

Or if you're like me and using Angular+ui-router you might try the following:

In your index.html add the following script:

<script type="text/javascript">
    setTimeout(function() {
        $('input').attr('autocomplete', 'off');
    }, 2000);
</script>

Then to cover state changes, add the following to your root controller:

$rootScope.$on('$stateChangeStart', function() {
                $timeout(function () {
                    $('input').attr('autocomplete', 'off');
                }, 2000);
            });

The timeouts are for the html to render before applying the jquery.

If you find a better solution please let me know.

TrampGuy
  • 1,737
  • 1
  • 13
  • 9
2

This worked for Edge & Chrome (not a login form tho, not sure if that makes a difference)

autocomplete="somerandomstring"

https://gist.github.com/niksumeiko/360164708c3b326bd1c8#gistcomment-2367048

softfrog
  • 60
  • 1
  • 8
  • it only works until you encounter the same `somerandomstring` more than once on the same computer. Perhaps if you use the current timestamp as the autocomplete.... – Garr Godfrey Nov 01 '21 at 21:34
1

Just autocomplete="off" list="autocompleteOff" in your input and work done !

1

autocomplete="off" doesn't work since yesterday (edge 105.0.1343.25). Looks like a bug to me. Hopefully, they will fix it soon.

veni
  • 41
  • 4
0

In the form field, try autocomplete="-"

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 09 '23 at 09:01
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/34650823) – Hemanth Kumar Jul 10 '23 at 05:56
-2

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