-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
46 lines (43 loc) · 1.24 KB
/
main.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
const cleaveCC = new Cleave("#cardNumber", {
creditCard: true,
delimiter: "-",
onCreditCardTypeChanged: function (type) {
const cardBrand = document.getElementById("cardBrand"),
visa = "fab fa-cc-visa",
mastercard = "fab fa-cc-mastercard",
amex = "fab fa-cc-amex",
diners = "fab fa-cc-diners-club",
jcb = "fab fa-cc-jcb",
discover = "fab fa-cc-discover";
switch (type) {
case "visa":
cardBrand.setAttribute("class", visa);
break;
case "mastercard":
cardBrand.setAttribute("class", mastercard);
break;
case "amex":
cardBrand.setAttribute("class", amex);
break;
case "diners":
cardBrand.setAttribute("class", diners);
break;
case "jcb":
cardBrand.setAttribute("class", jcb);
break;
case "discover":
cardBrand.setAttribute("class", discover);
break;
default:
cardBrand.setAttribute("class", "");
break;
}
},
});
const cleaveDate = new Cleave("#cardExpiry", {
date: true,
datePattern: ["m", "y"],
});
const cleaveCCV = new Cleave("#cardCcv", {
blocks: [3],
});