Switch off autocomplete for an HTML form fieldSwitch off autocomplete for an HTML form field

Posted December 6th, 2008 in HTML and CSS

Auto complete in form fields in web browsers can be extremely useful for helping a user to quickly complete a form. However there are times when you want to disable it, for example with the fields on a credit card payments form. This post looks at how to switch off autocomplete for an HTML form field.

The screenshot below shows auto complete in action on an example credit card form. As I started typing in the number 4 it offered a drop down box with all the cards entered that had started with 4 (in this example it only had a sample card number in the autocomplete history).

The red arrow in the screenshot shows the auto complete box.

example of auto complete working

You really don't want auto complete enabled for credit card fields in a form so this is a good example of a form field where it should be disabled.

A normal text field might look like this:

<input type="text" name="first_name" value=""  />

To switch off autocomplete simply add autocomplete="off" like so:

<input type="text" name="first_name" value="" autocomplete="off"  />

That's all there is to it. Now the auto complete popup won't appear for that field.

Related posts:

Share or Bookmark

Share or Bookmark this page using the following services. You will need to have an account with the selected service in order to post links or bookmark this page.

Subscribe or Follow

Subscribe via RSS or email, or follow me on Facebook or Twitter below. The RSS icon takes you through to Feedburner where you can select the service or application to use.

Comments

blog comments powered by Disqus