Safari autofill Credit Card

强颜欢笑 提交于 2021-02-06 08:58:46

问题


I am trying to use the code below to use "Safari's AutoFill" of the credit card. But it did not work

<input type="text" autocomplete="cc-number">
<input type="text" autocomplete="cc-name">
<input type="text" autocomplete="cc-exp-month">
<input type="text" autocomplete="cc-exp-year">
<input type="text" autocomplete="cc-csc">

回答1:


To make it work you need to:

  • Use any of this names: addCreditCardNumber, cardNumber, cardnumber -or- any of this ids: cardNumber, creditCardNumber, creditCardMonth, creditCardYear (there may be more ids or names that works)
  • Use an input with text type (not number type)
  • And most importantly it will only work over https

Hope this helps!




回答2:


I solved by using this ids:

<input type="text" id="cardNumber">
<input type="text" id="cardHolder">
<input type="text" id="cardExpirationMonth">
<input type="text" id="cardExpirationYear">
<input type="text" id="cardCsc">



回答3:


I'm having the same issues, Safari on iPhone simply refuses to populate the credit card expiration field. I tried using a single field, as well as separate fields for the MM and YYYY inputs.

According to https://html.spec.whatwg.org/multipage/forms.html#attr-fe-autocomplete the autocomplete value depends on whether the input field is wearing expectation mantle or anchor mantle. The latter meaning the field is a hidden input field, in which case on and off is not allowed, but the input should be from a list of autofill field names, listed on the WhatWG page.

The autocomplete value, as far as I can understand, should hint to the browser, what data to insert during autofill.

So far, I can't get this to work on Safari either...




回答4:


Auto complete attribute can only have on/off you can have your own values as you require, and you might have browser problems i do suggest u to look again at your form, it should be like..!!

<form action="demo_form.asp" method="get" autocomplete="on"> 



回答5:


It seems that the HTML Standard autofill tokens are working too (tested in Safari 11.1):

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill

For example:

<input type="text" autocomplete="cc-name"> Name<br/>
<input type="text" autocomplete="cc-number"> Number<br/>
<input type="text" autocomplete="cc-exp-month" size="2">/<input type="text" autocomplete="cc-exp-year" size="4"> Exp<br/>
<input type="text" autocomplete="cc-csc"> CSC<br/>

I found that expiration month and year should be next to each other in order to Safari to find it. CSC field will not be filled to maintain an another layer of security.



来源:https://stackoverflow.com/questions/21885412/safari-autofill-credit-card

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!