forked from GDSC-SIT-2024/HacktoberFest-Session24
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
68 lines (56 loc) · 1.65 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
62
63
64
65
66
67
68
$('.input-cart-number').on('keyup change', function(){
$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);
});
$('#card-holder').on('keyup change', function(){
$t = $(this);
$('.credit-card-box .card-holder div').html($t.val());
});
$('#card-holder').on('keyup change', function(){
$t = $(this);
$('.credit-card-box .card-holder div').html($t.val());
});
$('#card-expiration-month, #card-expiration-year').change(function(){
m = $('#card-expiration-month option').index($('#card-expiration-month option:selected'));
m = (m < 10) ? '0' + m : m;
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(){
});
}, 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()));
})*/