-
Notifications
You must be signed in to change notification settings - Fork 38
/
script.js
61 lines (52 loc) · 1.6 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
$('.input-cart-number').on('keyup change', function(){
var $t = $(this);
if ($t.val().length > 3) {
$t.next().focus();
}
var card_number = '';
$('.input-cart-number').each(function(){
card_number += $(this).val() + ' ';
if ($(this).val().length == 4) {
$(this).next().focus();
}
});
$('.credit-card-box .number').html(card_number.trim());
});
$('#card-holder').on('keyup change', function(){
var $t = $(this);
$('.credit-card-box .card-holder div').html($t.val());
});
$('#card-expiration-month, #card-expiration-year').change(function(){
var m = $('#card-expiration-month option').index($('#card-expiration-month option:selected'));
m = (m < 10) ? '0' + m : m;
var y = $('#card-expiration-year').val().substr(2,2);
$('.card-expiration-date div').html(m + '/' + y);
});
$('#card-ccv').on('focus', function(){
$('.credit-card-box').addClass('hover');
}).on('blur', function(){
$('.credit-card-box').removeClass('hover');
}).on('keyup change', function(){
$('.ccv div').html($(this).val());
});
/*--------------------
CodePen Tile Preview
--------------------*/
setTimeout(function(){
// Intentionally left empty or add relevant code here.
}, 500);
/*function getCreditCardType(accountNumber) {
if (/^5[1-5]/.test(accountNumber)) {
result = 'mastercard';
} else if (/^4/.test(accountNumber)) {
result = 'visa';
} else if ( /^(5018|5020|5038|6304|6759|676[1-3])/.test(accountNumber)) {
result = 'maestro';
} else {
result = 'unknown';
}
return result;
}
$('#card-number').change(function(){
console.log(getCreditCardType($(this).val()));
});*/