-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaadhaar.html
More file actions
132 lines (122 loc) · 3.9 KB
/
aadhaar.html
File metadata and controls
132 lines (122 loc) · 3.9 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Verhoeff's Check</title>
<style>
/* Base Styles */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
color: #333;
text-align: center; /* Center-align the content */
}
table {
margin: 0 auto;
text-align: left; /* Left-align table contents */
}
td {
padding: 10px;
}
input[type="text"] {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 3px;
}
input[type="button"] {
padding: 10px 20px;
background-color: #0074d9;
color: #fff;
border: none;
cursor: pointer;
}
/* Header Styles */
h1 {
font-size: 22px;
margin-bottom: 20px;
color: #0074d9;
}
/* Button Hover Effect */
input[type="button"]:hover {
background-color: #0056b3;
}
</style>
<script>
// JavaScript code for Verhoeff's Check
var FnF = new Array();
FnF[0] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
FnF[1] = [1, 5, 7, 6, 2, 8, 3, 0, 9, 4];
for (var i = 2; i < 8; i++) {
FnF[i] = [];
for (var j = 0; j < 10; j++)
FnF[i][j] = FnF[i - 1][FnF[1][j]];
}
var Dihedral = [
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[1, 2, 3, 4, 0, 6, 7, 8, 9, 5],
[2, 3, 4, 0, 1, 7, 8, 9, 5, 6],
[3, 4, 0, 1, 2, 8, 9, 5, 6, 7],
[4, 0, 1, 2, 3, 9, 5, 6, 7, 8],
[5, 9, 8, 7, 6, 0, 4, 3, 2, 1],
[6, 5, 9, 8, 7, 1, 0, 4, 3, 2],
[7, 6, 5, 9, 8, 2, 1, 0, 4, 3],
[8, 7, 6, 5, 9, 3, 2, 1, 0, 4],
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
];
var InverseD5 = [0, 4, 3, 2, 1, 5, 6, 7, 8, 9];
function VerhoeffCheck() {
var check = 0;
var IdValue = document.form.numcd.value;
for (var i = IdValue.length - 1; i >= 0; i--)
check = Dihedral[check][FnF[(IdValue.length - i - 1) % 8][IdValue.charAt(i)]];
if (check !== 0)
document.form.out.value = "INVALID";
else
document.form.out.value = "VALID";
}
function VerhoeffCompute() {
var IdValue = document.form.num.value;
var check = 0;
for (var i = IdValue.length - 1; i >= 0; i--)
check = Dihedral[check][FnF[(IdValue.length - i) % 8][IdValue.charAt(i)]];
document.form.numcd.value = document.form.num.value + InverseD5[check];
}
</script>
</head>
<body>
<h1>Aadhaar Number Validation with Verhoeff's Dihedral Algorithm</h1>
<form name="form">
<table>
<tr>
<td>Input Aadhaar Number (without last-digit)</td>
<td>
<input name="num" type="text" placeholder="Enter a numeric value" required>
</td>
<td>
<input id="computeBtn" type="button" value="Compute Last Digit" onclick="VerhoeffCompute()">
</td>
</tr>
<tr>
<td>Aadhaar Number with last-digit</td>
<td>
<input name="numcd" type="text">
</td>
<td>
<input id="checkBtn" type="button" value="Check" onclick="VerhoeffCheck()">
</td>
</tr>
<tr>
<td>Result of check</td>
<td>
<input name="out" type="text" size="6" readonly>
</td>
<td></td>
</tr>
</table>
</form>
</body>
</html>