最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to prevent Chrome from requesting to save credit card information - Stack Overflow

programmeradmin1浏览0评论

I am trying to find a way to programmatically disable Chrome's "Do you want save this credit card info" prompt.

I have tried adding autoplete="off" to all the inputs as well as the form, yet this prompt still es up.

Is there a way to disable this programmatically?

Unfortunately, this is different from Disable browser 'Save Password' functionality because this all revolves around tricking Chrome into thinking the input field is not a password field / simply using autoplete="off", however Chrome no longer acknowledges autoplete="off".

This is the banner I'm referring to:

I am trying to find a way to programmatically disable Chrome's "Do you want save this credit card info" prompt.

I have tried adding autoplete="off" to all the inputs as well as the form, yet this prompt still es up.

Is there a way to disable this programmatically?

Unfortunately, this is different from Disable browser 'Save Password' functionality because this all revolves around tricking Chrome into thinking the input field is not a password field / simply using autoplete="off", however Chrome no longer acknowledges autoplete="off".

This is the banner I'm referring to:

Share Improve this question edited May 23, 2017 at 12:22 CommunityBot 11 silver badge asked Mar 25, 2015 at 16:10 whatsnewsaeswhatsnewsaes 4252 gold badges5 silver badges13 bronze badges 6
  • Name the field to something else? – epascarello Commented Mar 25, 2015 at 16:17
  • possible duplicate of Disable browser 'Save Password' functionality – bviale Commented Mar 25, 2015 at 16:19
  • Already answered here : stackoverflow./questions/32369/… – bviale Commented Mar 25, 2015 at 16:19
  • Also answered here stackoverflow./a/29582380/4462191 – camiblanch Commented May 6, 2015 at 16:09
  • 7 All those answers relate to text box password fields and suggest setting autoplete="off" on the form. OP is asking about credit card info in Chrome on a form that already has autoplete="off". I am seeing the same behaviour and I agree with OP that Chrome is not acknowledging this and is offering autoplete for credit card details even when the form specifies not to. The other questions don't resolve this as they suggest things that OP has already tried and has stated aren't working. – Robin French Commented Jun 5, 2015 at 15:28
 |  Show 1 more ment

4 Answers 4

Reset to default 3

What I did is using a hidden field for Credit Card Number and Save the actual credit card number in it then clear the actual Credit Card number from screen by JScript.

I had the same problem you're experiencing; and with a newer browser version.

To resolve this, you have to set autoplete at form element.

<form autoplete="off" action="/cc.html" method="POST">
    <!-- Form fields -->
    <input type="text" name="cc" id="cc" />
    <!-- More form fields -->
</form>

For some reason Google Chrome ignores the autoplete="off" at <input type="text" /> for Credit Card prompts, but doesn't prompt when you set it with <form>.

I tried everything and had no success. The way I solved it, in the end, was actually to replace my label e.g. "Credit Card Number" with an image that contained the words "Credit Card Number", it worked a charm.

<div class="field">
   <div class="label">
      <img src="../images/cc-number.png">
   </div>
   <div class="value">
      <input type="text" name="ccnumber" id="ccnumber">
   </div>
</div>

There's a good reason why Chrome ignores autoplete="off" - it's not your information to decide whether or not the user's browser can save it. As such there is deliberately no way to disable this functionality programmatically.

You can make Chrome respect autoplete="off" by setting the appropriate flag in chrome://flags which would give you the oute you desire, but this only affects your browser - again, it's the user's information to decide to do with as they see fit.

发布评论

评论列表(0)

  1. 暂无评论