79657030

Date: 2025-06-07 14:16:37
Score: 2.5
Natty:
Report link

As I do not have the required number of posts to answer the question referred in the thread : [text](How do you disable browser autocomplete on web form field / input tags?) I wanted to share a solution **which solves the problem with all browsers and for all cases**. After having tried most of the solutions exposed and which still did not work for my case (*a language learning website with games consisting of questions and answers that students need to fill*), I wondered : "what is the HTML mechanism which allows to display the list of suggestions in an input field, whether in a form or not ?" The answer is a DATALIST ([text](https://www.w3schools.com/tags/tag_datalist.asp)) However setting an empty datalist for an input list is not sufficient. The complete answer is : HTML : ``` <input list="mysuggestions" name="myfield" id="myfield"> <datalist id="mysuggestions"></datalist> ``` Then adding on the focus in the field a reset of the datalist For instance in Javascript : ``` document.getElementById(myfield).addEventListener("focus", function(){document.getElementById("mysuggestions").innerHTML="";}); ``` Hope this helps...

Reasons:
  • Blacklisted phrase (1): did not work
  • Blacklisted phrase (1): How do you
  • Whitelisted phrase (-1): Hope this helps
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: user30744796