-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
56 lines (48 loc) · 1.7 KB
/
index.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
<html>
<head>
<title>ID Number Validators</title>
</head>
<body>
<h1>ID Number Validator</h1>
<p>
This ID Number Validator is powered by
<a href="https://github.com/imdreamrunner/js-id-number">js-id-number</a>.
It's a collection of identification number validators with uniform interfaces for JavaScript,
available for using in browsers and installed via NPM.
</p>
<h2>Validators</h2>
<p>Please do not block the alerts from browsers.</p>
<h3>Singapore NRIC Validator</h3>
<input id="sg-nric">
<input onclick="validate('SG', 'NRIC', 'sg-nric')" type="button" value="Validate!">
<h3>Tanwan ID Validator 台灣身份證字號驗證</h3>
<input id="tw-id">
<input onclick="validate('TW', 'ID', 'tw-id')" type="button" value="Validate!">
<h3>Chinese ID Validator 中国大陆公民身份号(居民身份证号码)</h3>
<input id="cn-id">
<input onclick="validate('CN', 'ID', 'cn-id')" type="button" value="Validate!">
<p>
Author: <a href="http://blog.dreamrunner.space/about.html">Ivor</a>
and <a href="https://github.com/imdreamrunner/js-id-number/graphs/contributors">GitHub contributors</a>.
</p>
<script src="dist/bin/IDNumber.js"></script>
<script>
function displayOutput(output) {
if (output.success) {
var message = "Success.";
if (output.extra) {
message += '\n' + JSON.stringify(output.extra);
}
alert(message)
} else {
alert("Error: " + output.reason);
}
}
function validate(country, type, input) {
var validator = IDNumber.getValidator(country, type);
var output = validator(document.getElementById(input).value);
displayOutput(output)
}
</script>
</body>
</html>