views:

165

answers:

2

I have an input field on a webpage that contains a credit-card number. What is the best way of preventing the browser from caching this value?

Any solution needs to work on a large selection of browsers.

+3  A: 
<asp:TextBox Runat="server" ID="Textbox1" autocomplete="off"></asp:TextBox>
Kobi
I can't believe I've not seen that before. I must have been living a bubble! Thanks.
Simon Johnson
The TextBox has an `AutoCompleteType`, but it doesn't support `off`. Also, womp's comment adds useful details on the subject. If you need this for security, maybe you need more...
Kobi
For further information on the `AutoCompleteType` enumeration, see [here](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.autocompletetype.aspx).It might not support, `Off` but it supports `Disabled`.
Simon Johnson
@Simon - I did check before I posted, and `Disables` didn't generate `autocomplete` for me. Odd. Possibly because I'm using Firefox/
Kobi
I've confirmed this myself. On that basis, I'm going to move the accepted answer to Juha. Thanks for the help!
Simon Johnson
+4  A: 

Put attribute autocomplete="off" to your html form. E.g.

<form name="form1" id="form1" method="post" autocomplete="off"
  action="http://www.example.com/form.cgi"&gt;
[...]
</form>

See this page.

Juha Syrjälä