Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing Browser Text Input Suggestions [duplicate]

I am building my own local search UI element that gives local search suggestions as you type. The problem I am having is that when I focus on the html text input element my browser (Safari, but could happen in other browsers) displays its own text suggestions based on things that I've typed in the past.

My guess is that this is dependent on the ID or Class of the < input > tag. So probably, if I change the input tag class to something obscure, the browser will not have any suggestions to offer. But I wonder if there isn't a more elegant way...

A related issue is about text field highlighting that happens in Safari when you focus on the < input > element. When I am filling up a form on Facebook, I don't see this outline. It would be great to hear if someone knows how to handle those two issues.

like image 787
David Haddad Avatar asked Apr 23 '09 21:04

David Haddad


People also ask

How do I stop textbox from auto filling?

Add autocomplete="off" onto <form> element; Add hidden <input> with autocomplete="false" as a first children element of the form.

How do I remove textbox suggestions in browser?

The solution is to add autocomplete=”off” attribute to textbox tag, which will help to stop auto suggestion behaviour for that particular textbox. And if you want to stop that behaviour for all the textboxes that are present inside a form then add autocomplete=”off” attribute to form tag..


1 Answers

Gecko-based browsers support a tag attribute called "autocomplete". So in your <form> tag you would put <form autocomplete="off">.

More here: How to turn off form autocompletion

Some other browsers have support for this as well. I believe IE will honor this.

like image 155
zombat Avatar answered Sep 29 '22 13:09

zombat