-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path银行卡类型查询.html
More file actions
114 lines (100 loc) · 3.38 KB
/
Copy path银行卡类型查询.html
File metadata and controls
114 lines (100 loc) · 3.38 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>银行卡类型查询工具</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #e6f7ff;
}
h1 {
text-align: center;
margin-top: 50px;
color: #1890ff;
font-size: 48px;
margin-bottom: 50px;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}
label {
font-size: 24px;
color: #1890ff;
margin-bottom: 20px;
}
input[type=text] {
padding: 10px;
font-size: 24px;
border-radius: 5px;
border: none;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
margin-bottom: 20px;
width: 80%;
max-width: 500px;
}
button {
padding: 10px 20px;
font-size: 24px;
color: #fff;
background-color: #1890ff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #096dd9;
}
.result {
margin-top: 50px;
font-size: 36px;
color: #1890ff;
}
</style>
</head>
<body>
<h1>银行卡类型查询工具</h1>
<form>
<label for="cardNumber">请输入银行卡号:</label>
<input type="text" id="cardNumber" placeholder="请输入银行卡号">
<button type="button" onclick="checkCardType()">查询</button>
</form>
<div class="result" id="result"></div>
<script>
function checkCardType() {
var cardNumber = document.getElementById("cardNumber").value.trim();
if (cardNumber.length == 0) {
alert("请输入银行卡号!");
return;
}
var reg = /^([1-9]{1})(\d{14}|\d{15}|\d{18})$/;
if (!reg.test(cardNumber)) {
alert("银行卡号格式不正确!");
return;
}
var prefix = cardNumber.substring(0,6); // 截取卡号前六位
var url = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardNo=" + cardNumber + "&cardBinCheck=true";
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onload = function () {
if (xhr.status === 200) { // 请求成功处理
var response = JSON.parse(xhr.responseText);
if (response.validated && response.cardType != "DC") { // 验证通过且不是借记卡
document.getElementById("result").textContent = "该银行卡为" + response.bank + response.cardType + "卡";
return;
}
}
document.getElementById("result").textContent = "该银行卡类型无法查询或为借记卡";
};
xhr.onerror = function () {
document.getElementById("result").textContent = "查询失败,请重试!";
};
xhr.send();
}
</script>
</body>
</html>