121

Possible Duplicate:
How do you disable browser Autocomplete on web form field / input tag?

I am building an application which will be accepting credit card data. I would like to make sure that the browser does not remember what has been typed into the text inputs for credit card number. I tried passing the following headers:

header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

Still, once the page reloads, I can click the credit card text input field and it will let me see what I wrote in it before. How can I prevent this?

4
  • 2
    This is not a server-side issue, it's the browser's autocomplete functionality at work. Commented Sep 24, 2011 at 15:57
  • 1
    I was also considering that this might be the case, but I made a little test: I went on PayPal to reset my password. Resetting the password involves entering the credit card number assigned to my account. I did this twice - the reset password page does NOT remember what I entered the first time in the credit card number field. Commented Sep 24, 2011 at 16:02
  • Is there a conclusion you can reach from that test? Commented Sep 24, 2011 at 16:05
  • I couldn't, that's what led me to asking the question here :) Commented Sep 24, 2011 at 16:17

2 Answers 2

216
<input type="text" autocomplete="off"/>

Should work. Alternatively, use:

<form autocomplete="off" … >

for the entire form (see this related question).

Sign up to request clarification or add additional context in comments.

2 Comments

That's not a related question, that's an exact duplicate.
@IgnacioVazquez-Abrams: An exact duplicate is by property a related question and the reciprocal is false.
15
<input type="text" autocomplete="off" />

2 Comments

But it is non-standard(?). Does it work in 2020?
@PeterMortensen Hi from 2022: It almost never works and browsers behave very differently (chrome being the one that ignores this the most)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.