Is it possible to use the autocomplete attribute in "textarea/select"?

Asked

Viewed 407 times

17

I know the attribute can be used in the element input

<input type="text" name="email" autocomplete="on" />

According to the MDN Web Docs, the element textarea includes the global attributes to which autocomplete but when testing in version 59.0.3 (64-bit) of Firefox, just didn’t work:

<textarea name="mensagem" autocomplete="on"></textarea>

See that in the session Browser Compatibility is said to work in the Firefox from the version 59, and researching on Google found places talking that works in Chrome from the version 66, but tested in version 66.0.3359.139 (Official version) 64 bits and it didn’t work either.

Already in the community WHATWG, it is stated that the attribute can be assigned both in elements textarea as in the elements select, but both do not work.

<select name="cor" autocomplete="on">
  <option value=""></option>
  <option value="Azul">Azul</option>
  <option value="Preto">Preto</option>
  <option value="Verde">Verde</option>
</select>

The question: I’m making the right use ?

References

  • I’m on my cell phone and I can’t get a good look, but it seems element interface defines the autocomplete as experimental, then you may need to enable support in your browser settings.

  • 1

    In select how would the autocomplete look? You want the user to type and already appear the combo options making a type of filter. Type starts typing the letter "A" and appears in combo the color "Blue" for example?

  • In the documentation is written: "on: The browser can automatically complete the value based on the values the user entered in previous sessions". That’s the behavior you’re testing?

  • @hugocsl this autocomplete will be the same as the input I believe, I believe it will be the browser standard, but as stated in the question, the documentation says that the attribute can be used in both elements, but it does not work in either of them.

  • Dude I don’t understand right rss, but it seems like you want a <datalist> and not a <select>...

  • http://www.endreywalder.com/blog/html5-autocomplete-with-optional-select/

  • @hugocsl no, it’s not datalist see the reference links I mentioned, see the attribute autocomplete

  • There is a way to do this through a Jquery library. http://api.jqueryui.com/autocomplete/ Follow below link of this working example. http://output.jsbin.com/cezemetida/1 Here’s the Stackoverflow response link. https://stackoverflow.com/questions/2518442/autocomplete-functionality-on-a-textarea A hug !

Show 3 more comments

1 answer

10

The autocomplete in the elements textarea and select has a different behaviour in relation to the elements input.

While we inputs the autocomplete (when set on) is activated when you start typing and the browser displays values already typed (stored in the cache) that match what you are typing at that time, on textarea and select it works only when the page suffers a Reload with cache, that is by typing F5, CTRL+R or by clicking the browser button, keeping:

  • In the textarea: the text that was typed before the refresh.

  • In the select: to option selected before refresh.

In short, the function of autocomplete in those elements (textarea and select) is nothing more than keep the values (on) or not keep (off) by making a Reload simple as mentioned earlier.

But you’ll notice if there is no attribute autocomplete in the element, the browser will keep the values anyway, as if it had a autocomplete="on". Hence, the autocomplete becomes useful only with the value off, when you do not in any way want the values to remain in the elements even after a Reload simple.

Recalling that this approach refers exclusively to Firefox at version equal or higher than the one pointed out in the question (I am using Firefox version 60.0.1 64-bit) and also as reported in the compatibility table of documentation on MDN.

Edit

Don’t imagine that the autocomplete="on" in the textarea or select will make suggestions appear as it appears in the fields input. This doesn’t exist yet (and I think it’s good :D).

  • Okay, I didn’t know that, but what about Chrome ?

  • From the compatibility table, Chrome doesn’t have support. Where did you see it supports? By the tests I performed here, the autocomplete has no effect on Chrome in textarea and select.

  • In the MDN the documentation of select there is no autocomplete already in the WHATWG - select appears.

  • If you take a look at the table on Can I Use you will see that there are many "caveats" for using the autocomplete in different browsers.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.