Skip to content

Commit

Permalink
More autocomplete updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesreggio committed Jul 16, 2014
1 parent 6a97e4e commit 53f095b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ We recommend you turn autocomplete on for credit card forms, except for the CVC
You should also mark up your fields using the [Autocomplete Types spec](http://wiki.whatwg.org/wiki/Autocomplete_Types). These are respected by a number of browsers, including Chrome.

``` html
<input type="text" class="cc-number" pattern="\d*" autocompletetype="cc-number" placeholder="Card number" required>
<input type="text" class="cc-number" pattern="\d*" autocomplete="cc-number" placeholder="Card number" required>
```

Set `autocompletetype` to `cc-number` for credit card numbers and `cc-exp` for credit card expiry.
Set `autocomplete` to `cc-number` for credit card numbers and `cc-exp` for credit card expiry.

## Mobile recommendations

Expand Down
11 changes: 6 additions & 5 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
</style>

<script>
jQuery(function($){
jQuery(function($) {
$('[data-numeric]').payment('restrictNumeric');
$('.cc-number').payment('formatCardNumber');
$('.cc-exp').payment('formatCardExpiry');
$('.cc-cvc').payment('formatCardCVC');

$('form').submit(function(e){
$('form').submit(function(e) {
e.preventDefault();
$('input').removeClass('invalid');
$('.validation').removeClass('passed failed');
Expand All @@ -38,7 +38,7 @@
$('.cc-exp').toggleClass('invalid', !$.payment.validateCardExpiry($('.cc-exp').payment('cardExpiryVal')));
$('.cc-cvc').toggleClass('invalid', !$.payment.validateCardCVC($('.cc-cvc').val(), cardType));

if ( $('input.invalid').length ) {
if ($('input.invalid').length) {
$('.validation').addClass('failed');
} else {
$('.validation').addClass('passed');
Expand All @@ -57,10 +57,11 @@ <h2>Card number formatting</h2>

<h2>Expiry formatting</h2>

<input type="text" class="cc-exp" pattern="\d*" autocomplete="cc-exp" placeholder="Expires MM/YY" required maxlength="9">
<input type="text" class="cc-exp" pattern="\d*" autocomplete="cc-exp" placeholder="Expires MM/YY" required>

<h2>CVC formatting</h2>
<input type="text" class="cc-cvc" pattern="\d*" autocomplete="cc-csc" placeholder="Security code" required autocomplete="off">

<input type="text" class="cc-cvc" pattern="\d*" autocomplete="off" placeholder="Security code" required>

<h2>Restrict Numeric</h2>

Expand Down

0 comments on commit 53f095b

Please sign in to comment.