2

I was wondering if there is any way to disable autofill for credit card information. As I'm aware the autocomplete"off" attribute does not work for CC options. I also tried to use: autocomplete="doNotAutoComplete".

Currently the textbox looks like this:

<asp:TextBoxID="_creditCardHolderNameTextBox"runat="server" MaxLength="100"/>

I've thought of two common solutions for the problem, renaming the ID to something random that Chrome can't pick up, however I don't want to do this for two reasons: 1) It's just bad practice 2) There are a lot of things in the code using this textbox and renaming it all causes heaps of errors and gets extremely messy really quickly.

The other thing was creating "Fake" CC Inputs as mentioned by Mike Nelson this post: Disabling Chrome Autofill

The only problem with this is the code I'm currently working with uses a repeater to generate the form, it's also extremely messy and volatile messing with it.

Any ideas?

  • 1
    I find myself wanting to know the use case for this. Autofill is a browser setting, so it sounds like your application is trying to control client-side behavior. In general, this makes for a frustrating user experience. – neontapir Mar 05 '19 at 03:44
  • Although I do agree with you that in 99% of circumstances it should stay but in our case our policies are written up by third parties for customers, there have apparently been some issues coming in as a result of this. Also as a business decision and as a junior dev it's kind of out of my hands – Kyle Russell Mar 05 '19 at 03:47
  • I hear you. Another way to ask this question is, what problem are you trying to solve by disabling autofill? The answer could determine which approaches are appropriate. – neontapir Mar 05 '19 at 03:52

1 Answers1

1

UPDATE: In case anyone was wondering I found out a couple of solutions to this problem.

Google defines that the fields are Credit Card inputs by the following factors: The label Proceeding the input, the id of the input and the name attribute (if applicable).

So in short the quickest and most simple solution is to just change the id, name and label to something unrelated to the CC details.

For the label I found the easiest solution to be to wrap a label around each word e.g.

<label>Credit</label> <label>Card</label> <label>Number:</label>

(Very sloppy solution but gets the job done)

The second problem is the id and name, for this I found the best solution to be to use a script that changes these dynamically then passes them back before submission of the form. Check out this awesome Jquery script by Terry Lin (terrylinooo) which does just that!

https://terrylinooo.github.io/jquery.disableAutoFill/