My application has a search textfield, and I’d like to offer a autocomplete/autosuggest functionality, preferably without rolling my own.
The input type="search"
element appears to suit my purposes.
<input type="search" placeholder="search" name="q"/>
For me, the above input will provide auto complete suggests that appear to come from Github.
Though I believe that’s because it share the name
property with Github’s issue search, Github’s issue search element is:
<input
type="text"
name="q"
id="js-issues-search"
value="is:issue is:open "
class="form-control form-control subnav-search-input input-contrast width-full"
placeholder="Search all issues"
aria-label="Search all issues"
data-hotkey="Control+/,Meta+/">
The concern is – I don’t want searches from other websites polluting mine, nor do I want searches from my website polluting others.
How can instruct the browser to constrain the autocomplete to this website only?
I suppose I could put a unique looking name
attribute in, but is there a better way?
2
Answers
put
autocomplete="off"
in your input. This property should turn off the auto complete feature for users.according to the official HTML Standard,
autocomplete
values areon
,off
or a<token-list>
. I guess that according to what info you want to be auto-completed, you have to provide a list of tokens.for concrete, examples check the standard