117

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Boyan Georgiev
  • 1,521
  • 2
  • 13
  • 16
  • 2
    This is not a server-side issue, it's the browser's autocomplete functionality at work. – Jon Sep 24 '11 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. – Boyan Georgiev Sep 24 '11 at 16:02
  • Is there a conclusion you can reach from that test? – Jon Sep 24 '11 at 16:05
  • I couldn't, that's what led me to asking the question here :) – Boyan Georgiev Sep 24 '11 at 16:17

2 Answers2

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

Should work. Alternatively, use:

<form autocomplete="off" … >

for the entire form (see this related question).

Community
  • 1
  • 1
user703016
  • 37,307
  • 8
  • 87
  • 112
14
<input type="text" autocomplete="off" />
Ryan
  • 14,392
  • 8
  • 62
  • 102