I have a input
field which shows a list using html5 <datalist>
element. The problem is that with <datalist>
the browser autocomplete also shows the history list (which is the list of previously typed values, that are not included in the <datalist>
). So I just want to get rid of the history-list
not the <datalist>
.
If I use the autocomplete = "off"
feature, this also blocks the <datalist>
.
In short, I just want the <datalist>
not the history one.
Try using the HTML attribute autocomplete
source Turn Off Autocomplete for Input
Try this, I hope its work
Best wishes
try this:
js:
This will clear the datalist's history. This worked for me on chrome. Then if you want to add options to the list, try:
Cheers !!!
Is it possible for you to use the
input
field without anid
orname
attribute? Without that, the browser doesn't really have any way to associate a history with that element.In my real quick testing on Firefox, this seemed to do the trick:
In the code above, the
input
s with anid
orname
would remember past values, but theinput
without anything and the input with just aclass
would not remember anything.Unfortunately, this does make using the
input
slightly more difficult if you need it to have aname
orid
. In that case, I'd try having anid
'edinput
which is alsodisplay: none
'ed and then use some JavaScript to keep it in sync with aninput
that won't remember past values.I use a code like this:
good: The datalist shown for selection is complete
bad : The input field is empty, therefore the old value is not documented, if needed to be remembered by the user