views:

616

answers:

5

When typing in html forms, browsers like firefox or ie 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.

In a e-commerce website, the customer type 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 a malware, by example). Then the customer can select this contaminated data and compromise the site.

Regards.

+2  A: 

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"&gt;
[...]
</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");
CMS
+2  A: 

See a longer discussion here:

http://stackoverflow.com/questions/2530/how-do-you-disable-browser-autocomplete-on-web-form-field

It looks like autocomplete="off" will work in some cases but it is not XHTML compliant.

BobbyShaftoe
A: 

You can put on the input fields:

autocomplete="off"

as an attribute.

That being said: DON'T DO IT.

From a usability standpoint it is a terrible idea. Particularly if there's field validation. There's nothing more annoying than having to retype parts of a form because you have to correct a completely unrelated form. Most users like the fact that they don't have to retype in credit card numbers, their name, email addresses, etc.

You will annoy far more users than you help by turning off such features.

Ultimately, security is the user's problem and their perogative. The vast majority of people use personal or work PCs so are fine with caching such information. Properly configured public terminals will clear form data when the user logs off.

So who exactly are you helping?

cletus
This shouldn't be downvoted. However, as for the bit about "security is the user's perogative," I think that's not necessarily the right attitude. You may be building a business application where one of the requirements is to not allow these autocomplete fields. But you may have a point sometimes.
BobbyShaftoe
Saying security is the user's problem is taking it too far, but +1 for the general gist. I hate forms that disable the autocomplete and/or use non-standard (read "stupid") field names (like "EmailAddy").
Software Monkey
Stopping browsers storing credit card numbers shouldn't be left to users. Too many users won't even realise it's a problem.
Sam Hasler
It's particularly important for a card security code. As this page http://is.gd/gZVD says "Never store the security code ... its value depends on the presumption that the only way to supply it is to read it from the physical credit card, proving that the person supplying it actually holds the card."
Sam Hasler
The problem is, if it's a public computer (cyber cafe, library etc) it's then easy for other users to steal your card details, and even on your own machine a malicious website could steal autocomplete data. See http://webreflection.blogspot.com/2008/09/security-basis-and-internet-explorer.html
Sam Hasler
Disagree here with cletus - it is the responsibility of the developer to comply with the credit card industry's rules. I think annoying the users is acceptable WRT card numbers + security codes, because it helps with your PCI compliance. Often users are the weakest link in the security chain!
Travis Leleu
+1  A: 

As others have said, the answer is autocomple="off"

However I think it's worth stating why it's a good idea to use this in certain cases as some answers to this and duplicate questions have suggested it's better not to turn if off.

Stopping browsers storing credit card numbers shouldn't be left to users. Too many users won't even realise it's a problem.

It's particularly important to turn it off on fields for credit card security codes. As this page states

"Never store the security code ... its value depends on the presumption that the only way to supply it is to read it from the physical credit card, proving that the person supplying it actually holds the card."

The problem is, if it's a public computer (cyber cafe, library etc) it's then easy for other users to steal your card details, and even on your own machine a malicious website could steal autocomplete data.

Sam Hasler
+1  A: 

It is good to use the autocomplete="off" for public computers when you store data like usernames, credit card numbers and such.

So if you build a intranet system it would be OK to do it.