Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I do to force the browser to not store the HTML form field data?

When typing in HTML forms, browsers like Firefox or Internet Explorer store the values, sometimes quietly. So when typing in another webforms, the browser smartly suggest the same information. Another method to show the dropdown list is double-clicking an empty textbox.

On an E-commerce website, the customer types the credit card number, and another sensitive information. How I do to avoid or block the browser to store that sensitive information?

Another worry is about tampered form data stored (by malware, by example). Then the customer can select this contaminated data and compromise the site.

like image 327
Click Ok Avatar asked Jan 23 '09 03:01

Click Ok


1 Answers

Try with the atribute autocomplete="off"

It should work for single input elements:

<input type="text" autocomplete="off" name="text1" />

or to the entire form:

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

And specifically for ASP .NET you can set it like this:

The WebForms form:

<form id="Form1" method="post" runat="server" autocomplete="off">

Textboxes:

<asp:TextBox Runat="server" ID="Textbox1" autocomplete="off"></asp:TextBox>

or at runtime:

Textbox1.Attributes.Add("autocomplete", "off");
like image 50
Christian C. Salvadó Avatar answered Sep 18 '22 13:09

Christian C. Salvadó