blob: 1a96601941a42adb72d8f31c417f664eb582389b (
plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
<!DOCTYPE html>
<html lang="en">
<head>
<%- include('partials/head') %>
</head>
<body>
<%- include('partials/navbar') %>
<div class="ui container segment" >
<form class="ui form" method="post" onsubmit="editCitizen(event)" >
<div class="field">
<label>Citizen ID</label>
<input
placeholder="Citizen ID"
name="citizen_id"
type="text"
autocomplete="off"
id="citizen_id"
/>
</div>
<div class="field">
<label>First Name</label>
<input
placeholder="First Name"
name="first_name"
type="text"
autocomplete="off"
id="first_name">
</div>
<div class="field">
<label>Last Name</label>
<input
placeholder="Last Name"
name="last_name"
type="text"
autocomplete="off"
id="last_name">
<div>
<div class="field">
<label>Address</label>
<input
placeholder="Address"
name="address"
type="text"
autocomplete="off"
id="address"
/>
</div>
<div class="field">
<label>Mobile Number</label>
<input
type="text"
name="mobile_number"
placeholder="Mobile Number"
id="mobile_number"
/>
</div>
<div class="field">
<label>Date of Birth</label>
<input type="date" name="dob" placeholder="DOB" id="dob" />
</div>
<div class="field">
<label>Marital Status</label>
<select class="ui dropdown" id="marital_status">
<option value="M">Married</option>
<option value="UM">Unmarried</option>
</select>
</div>
<div class = "field">
<label>disabled</label>
<select class="ui dropdown" id="disabled">
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div>
<div class="field">
<label>Disabled Percentage</label>
<input
type="text"
name="disabled_percentage"
placeholder="Disabled Percentage"
id="disabled_percentage"
/>
</div>
<div class="field">
<label>Caste</label>
<input
type="text"
name="caste"
placeholder="Caste"
id="caste"
/>
</div>
<div class="field">
<label>State</label>
<select class="ui dropdown" id="state">
</select>
</div>
<div class="field">
<label>District</label>
<select class="ui dropdown" id="district">
</select>
</div>
<div class="field">
<lable>Mandal</lable>
<select class="ui dropdown" id="mandal">
</select>
</div>
<div class="field">
<label>Village Name</label>
<select class="ui dropdown" id="village">
</select>
</div>
<div class="ui primary button" id="editCitizen">Submit</div>
<div class="ui error message"></div>
</form>
</div>
</body>
<%- include('partials/scripts') %>
<script>
//gereate random data with Upper case letter with seven digit number
function generateCitizenId() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var possible2 = "0123456789";
text += possible.charAt(Math.floor(Math.random() * possible.length));
for (var i = 0; i < 7; i++)
text += possible2.charAt(Math.floor(Math.random() * possible2.length));
//validate user name with database
fetch("/api/citizens/validate", {
method: "POST",
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({citizen_id: text})
}).then(res => {
if(res.status == 200){
document.getElementById("citizen_id").value = text;
}
else{
generateCitizenId();
}
});
}
generateCitizenId();
</script>
</html>
|