-
Notifications
You must be signed in to change notification settings - Fork 79
/
demo.html
104 lines (101 loc) · 2.45 KB
/
demo.html
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
<!DOCTYPE html>
<html>
<head>
<title>Mtils test page</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<style type="text/css">
.center {
width: 600px;
margin: 0px auto;
}
.center div {
margin-top: 5px;
}
</style>
<body>
<div class="center">
<div><h1>Mtils简单示例</h1></div>
<div>
<lable>身份证校验:</lable>
<input id="idcard" type="text">
<button onclick="demo.checkId()">校验身份证</button>
</div>
<div>
<lable>银行卡校验:</lable>
<input id="bankcard" type="text">
<button onclick="demo.checkBankcard()">校验银行卡</button>
</div>
<div>
<lable>社会信用代码:</lable>
<input id="creditCode" value="" type="text">
<button onclick="demo.checkCreditCode()">校验信用代码</button>
</div>
<div>
<lable>Url校验:</lable>
<input id="url" type="text">
<button onclick="demo.checkUrl()">校验URL</button>
</div>
<div>
<lable>生成MD5:</lable>
<input id="md5" type="text">
<button onclick="demo.createMD5()">生成MD5</button>
</div>
<div>
<lable>生成sha_256:</lable>
<input id="sha256" type="text">
<button onclick="demo.createSHA256()">生成sha256</button>
</div>
<div>
<lable>计算年龄:</lable>
<input id="calcAge" value="1992-04-23" type="text">
<button onclick="demo.calcAge()">计算年龄</button>
</div>
</div>
</body>
<script type="text/javascript">
var val = function(id) {
return document.getElementById(id).value;
}
var demo = {
checkId : function() {
if(Mtils.validation.isIdCard(val("idcard"))) {
alert(true);
} else {
alert(false);
}
},
checkBankcard : function() {
if(Mtils.validation.isBankCard(val("bankcard"))) {
alert(true);
} else {
alert(false);
}
},
checkCreditCode : function() {
if(Mtils.validation.isCreditCode(val("creditCode"))) {
alert(true);
} else {
alert(false);
}
},
checkUrl : function() {
if(Mtils.validation.isUrl(val("url"))) {
alert(true);
} else {
alert(false);
}
},
createMD5 : function() {
alert(val("md5") + "的加密码是:" + Mtils.security.hex_md5(val("md5")))
},
createSHA256 : function() {
alert(val("sha256") + "的加密码是:" + Mtils.security.hex_sha256(val("sha256")))
},
calcAge : function() {
alert("你今年" + Mtils.utils.calcAge(val("calcAge"), new Date()) + "岁")
}
};
</script>
<script type="text/javascript" src="Mtils.min.js"></script>
</html>