-
Notifications
You must be signed in to change notification settings - Fork 0
/
task14.html
225 lines (187 loc) · 8.29 KB
/
task14.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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Javascript - Task 8</title>
<style>
table,
th,
td {
border: none;
}
.col1{
width: 200px;
text-align: right;
padding-right: 3%;
}
.col2{
width: 1000px;
}
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
h3 {
color: blue;
padding-top: 2%;
}
table {
padding: 20px;
}
.poor, .password-mismatch {
color: red;
}
.perfect, .password-match {
color: green;
}
span{
color: red;
}
input{
width: 80%;
}
</style>
</head>
<body>
<center>
<form style="background: linear-gradient(to bottom, #eceb7f, #d81edf); width: 50%">
<table>
<h3>Registration Form</h3>
<tr>
<td class="col1"><label for="fname">First Name</label> </td>
<td class="col2"><input type="text" id="fname" name="fname" required onkeyup="checkFieldStrength('fname')">
<span class="strength-indicator">POOR</span></td>
</tr>
<tr>
<td class="col1"><label for="lname">Last Name</label> </td>
<td class="col2"><input type="text" id="lname" name="lname" onkeyup="checkFieldStrength('lname')" required>
<span class="strength-indicator">POOR</span></td>
</tr>
<tr>
<td class="col1"><label for="mail">Email</label></td>
<td class="col2"><input type="email" id="mail" name="mail" onkeyup="checkFieldStrength('mail')">
<span class="strength-indicator">POOR</span></td>
</tr>
<tr>
<td class="col1"><label for="pass">Password</label></td>
<td class="col2"><input type="password" id="pass" name="pass" maxlength="12" onkeyup="checkFieldStrength('pass')" required>
<span class="strength-indicator">POOR</span></td>
</tr>
<tr>
<td class="col1"><label for="repass">Re-enter Password</label></td>
<td class="col2"><input type="password" id="repass" name="repass" maxlength="12" onkeyup="checkPasswordMatch()" required>
<span class="password-match-indicator">MISMATCH</span>
</tr>
<tr>
<td class="col1"><label>Gender: </label></td>
<td>
<input type="radio" name="gender" style="width: 15%" />Male
<br>
<input type="radio" name="gender" style="width: 15%" />Female
</td>
</tr>
<tr>
<td class="col1"><label for="age">Age: </label></td>
<td class="col2"><input type="number" id="age" name="age" min="0" max="99" required>
<span class="strength-indicator">POOR</span></td>
</tr>
<tr>
<td class="col1"><label for="phone">Phone Number: </label></td>
<td class="col2"><input type="number" id="phone" name="phone" min="10" max="10" onkeyup="checkFieldStrength('phone')" required>
<span class="strength-indicator">INVALID</span></td>
</tr>
<tr>
<td class="col1"><label>Address</label></td>
<td class="col2"><textarea style="width: 81%; height: 100px" id="addr" onkeyup="checkFieldStrength('addr')" required></textarea>
<span class="strength-indicator">POOR</span></td>
</tr>
<tr>
<td class="col1"><label for="state"></label>State</td>
<td class="col2"><input type="state" id="state" name="state" onkeyup="checkFieldStrength('state')" required>
<span class="strength-indicator">POOR</span></td>
</tr>
<tr>
<td class="col1"><label>Country</label></td>
<td class="col2">
<select>
<option>Choose your country</option>
<option>India</option>
<option>Singapore</option>
<option>Nepal</option>
<option>Sri Lanka</option>
</select>
</td>
</tr>
<tr>
<td class="col1"><label>Languages known</label></td>
<td class="col2">
<input style="width: 5%" type="checkbox" />English
<input style="width: 5%" type="checkbox" />Kannada
<input style="width: 5%" type="checkbox" />Hindi
<input style="width: 5%" type="checkbox" />Telugu
</td>
</tr>
<tr>
<td colspan="2">
<input style="width: 10%" type="checkbox" checked /> Hereby I declare all the given details are true
</td>
</tr>
<tr>
<td align="right" colspan="2">Login to <a href="https://ethnus.com/"
style="color: purple;">Ethnus</a> website</td>
</tr>
</table>
<br>
<input type="submit" value="Register" align="center" style="margin-bottom: 2%; width: 15%;" />
</form>
</center>
<script>
function checkFieldStrength(fieldId) {
const field = document.getElementById(fieldId);
const fieldStrengthIndicator = field.parentNode.querySelector('.strength-indicator');
// Reset classes and content
fieldStrengthIndicator.className = "strength-indicator";
fieldStrengthIndicator.textContent = "";
if (fieldId === "phone") {
if (field.value.length === 10) {
fieldStrengthIndicator.textContent = "Perfect";
fieldStrengthIndicator.classList.add("perfect");
}
else {
fieldStrengthIndicator.textContent = "INVALID";
fieldStrengthIndicator.classList.add("poor");
}
}
else{
// Check field value length and set strength indicator
if (field.value.length < 5) {
fieldStrengthIndicator.textContent = "POOR";
fieldStrengthIndicator.classList.add("poor");
}
else {
fieldStrengthIndicator.textContent = "Perfect";
fieldStrengthIndicator.classList.add("perfect");
}
}
}
function checkPasswordMatch() {
const passField = document.getElementById("pass");
const repassField = document.getElementById("repass");
const passwordMatchIndicator = repassField.parentNode.querySelector('.password-match-indicator');
// Reset classes and content
passwordMatchIndicator.className = "password-match-indicator";
passwordMatchIndicator.textContent = "";
// Check if passwords match and set match indicator
if (passField.value === repassField.value) {
passwordMatchIndicator.textContent = "MATCH";
passwordMatchIndicator.classList.add("password-match");
} else {
passwordMatchIndicator.textContent = "MISMATCH";
passwordMatchIndicator.classList.add("password-mismatch");
}
}
</script>
</body>
</html>