Prevent Auto Complete on HTML input fields in a web form

My client would like me to change the behavior of a web form. They want to prevent auto complete from showing a list of recent entries when they click on a text field.

For example, if there is an "Email" text box, when you click on the field and hit a letter, a list of recent email addresses will show up.

One way of getting rid of the auto complete stuff is to clear the browser cache. I need to replicate this behavior programatically. Anything I can do to prevent the auto complete from working is good with me.

One other thing I thought of, I could randomize the "name" or "id" of the text fields, but that would cause problems on the submit side of things.

Sometimes with dynamic images, to prevent them from caching I append a random query string parameter to the image SRC; IE:

<img src="myPhoto.jpg?randomstring_829304">

Of course this is probly unrelated.

Anyone know an easy way to disable auto complete using code (ASP.NET or HTML or JAVASCRIPT)
<form>
<input type="text" name="email" /><!-- No auto complete please! -->
</form>

Open in new window

LVL 3
JenniQAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chad HaneyChief Technology OfficerCommented:
Disable it by putting autocomplete="off" in the form tag.   Only way to do it is by turning it off for the whole form.
<form autocomplete="off">
<input type="text" name="email" /><!-- No auto complete please! -->
</form>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
baiju_nagoriCommented:
You can do this at field level too
<form>
<input type="text" name="email"  autocomplete="off"  />
</form>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.