-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
298 lines (235 loc) · 10.5 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
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<title>BMI Calculator</title>
</head>
<!-- Here is a comment :) -->
<body>
<form id="f1" class="modal-content" action="cgi/bmi_calculator.pl" method="post" onsubmit="passcheck();">
<div class="container2">
<h1>Sign Up</h1>
<p>Please fill in this form to create an account.</p>
<hr>
<label for="fname">First Name</label>
<input type="text" id="fname" name="firstname" class="input" placeholder="Your name.." required>
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lastname" class="input" placeholder="Your last name.." required>
<label for="email"><b>Email</b></label>
<input type="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" placeholder="Enter Email" id="email" name="email" required>
<label for="country">Country</label>
<select id="country" name="country">
<option value="australia">Australia</option>
<option value="canada" selected>Canada</option>
<option value="usa">USA</option>
</select>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*+`~=?\|<>/]).{8,}" class="input" name="psw" id="psw" required>
<label for="psw-repeat"><b>Repeat Password</b></label>
<input type="password" placeholder="Repeat Password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*+`~=?\|<>/]).{8,}" name="psw-repeat" class="input" id="psw-repeat" required>
<label>
<input type="checkbox" checked="checked" name="remember" style="margin-bottom:15px"> Remember me
</label>
<p>By creating an account you agree to our <a href="#" style="color:dodgerblue">Terms & Privacy</a>.</p>
<div class="clearfix">
<button type="button" onclick="document.getElementById('myModal').style.display='none'" class="cancelbtn">Cancel</button>
<button type="submit" class="signupbtn">Sign In</button>
</div>
</div>
<div id="message">
<h3>Password must contain the following:</h3>
<p id="letter" class="invalid">A <b>lowercase</b> letter</p>
<p id="capital" class="invalid">A <b>capital (uppercase)</b> letter</p>
<p id="number" class="invalid">A <b>number</b></p>
<p id="specialchar" class="invalid">A <b>Special Character</b></p>
<p id="length" class="invalid">Minimum <b>8 characters</b></p>
</div>
<div id="message2">
<h3>Password must contain the following:</h3>
<p id="letter2" class="invalid">A <b>lowercase</b> letter</p>
<p id="capital2" class="invalid">A <b>capital (uppercase)</b> letter</p>
<p id="number2" class="invalid">A <b>number</b></p>
<p id="specialchar2" class="invalid">A <b>Special Character</b></p>
<p id="length2" class="invalid">Minimum <b>8 characters</b></p>
</div>
</form>
<script language="javascript">
//-------------SANITIZE TEXT----------------
var fname = document.getElementById("fname");
var lname = document.getElementById("lname");
var email = document.getElementById("email");
//Sanitize for numbers
fname.onkeyup = function() {
var numbers = /[0-9]/g;
if(fname.value.match(numbers)) {
alert("Invalid Input");
fname.value ="";
}
// Sanitize for Special Char except @
var specialchar = /[!#$%^&*+`~=?\|<>/]/g;
if(fname.value.match(specialchar)) {
alert("Invalid Input");
fname.value ="";
}
}
lname.onkeyup = function() {
var numbers = /[0-9]/g;
if(lname.value.match(numbers)) {
alert("Invalid Input");
lname.value ="";
}
// Sanitize for Special Char except @
var specialchar = /[!#$%^&*+`~=?\|<>/]/g;
if(lname.value.match(specialchar)) {
alert("Invalid Input");
lname.value ="";
}
}
email.onkeyup = function() {
// Sanitize for Special Char except @
var specialchar = /[!#$%^&*+`~=?\|<>/]/g;
if(email.value.match(specialchar)) {
alert("Invalid Input");
email.value ="";
}
}
//----------PASSWORD AUTHENTICATION----------------
var mypass = document.getElementById("psw");
var mypassrp = document.getElementById("psw-repeat");
var letter = document.getElementById("letter");
var capital = document.getElementById("capital");
var number = document.getElementById("number");
var length = document.getElementById("length");
var char = document.getElementById("specialchar");
// ------------PASSWORD----------------------
// When the user clicks on the password field, show the message box
mypass.onfocus = function() {
document.getElementById("message").style.display = "block";
}
// When the user clicks outside of the password field, hide the message box
mypass.onblur = function() {
document.getElementById("message").style.display = "none";
}
// When the user starts to type something inside the password field
mypass.onkeyup = function() {
// Validate lowercase letters
var lowerCaseLetters = /[a-z]/g;
if(mypass.value.match(lowerCaseLetters)) {
letter.classList.remove("invalid");
letter.classList.add("valid");
} else {
letter.classList.remove("valid");
letter.classList.add("invalid");
}
// Validate capital letters
var upperCaseLetters = /[A-Z]/g;
if(mypass.value.match(upperCaseLetters)) {
capital.classList.remove("invalid");
capital.classList.add("valid");
} else {
capital.classList.remove("valid");
capital.classList.add("invalid");
}
// Validate numbers
var numbers = /[0-9]/g;
if(mypass.value.match(numbers)) {
number.classList.remove("invalid");
number.classList.add("valid");
} else {
number.classList.remove("valid");
number.classList.add("invalid");
}
// Validate Special Char
var specialchar = /[!@#$%^&*+`~=?\|<>/]/g;
if(mypass.value.match(specialchar)) {
char.classList.remove("invalid");
char.classList.add("valid");
} else {
char.classList.remove("valid");
char.classList.add("invalid");
}
// Validate length
if(mypass.value.length >= 8) {
length.classList.remove("invalid");
length.classList.add("valid");
} else {
length.classList.remove("valid");
length.classList.add("invalid");
}
}
// ------------REPEAT PASSWORD----------------------
var letter2 = document.getElementById("letter2");
var capital2 = document.getElementById("capital2");
var number2 = document.getElementById("number2");
var length2 = document.getElementById("length2");
var char2 = document.getElementById("specialchar2");
// When the user clicks on the password field, show the message box
mypassrp.onfocus = function() {
document.getElementById("message2").style.display = "block";
}
// When the user clicks outside of the password field, hide the message box
mypassrp.onblur = function() {
document.getElementById("message2").style.display = "none";
}
// When the user starts to type something inside the password field
mypassrp.onkeyup = function() {
// Validate lowercase letters
var lowerCaseLetters = /[a-z]/g;
if(mypassrp.value.match(lowerCaseLetters)) {
letter2.classList.remove("invalid");
letter2.classList.add("valid");
} else {
letter2.classList.remove("valid");
letter2.classList.add("invalid");
}
// Validate capital letters
var upperCaseLetters = /[A-Z]/g;
if(mypassrp.value.match(upperCaseLetters)) {
capital2.classList.remove("invalid");
capital2.classList.add("valid");
} else {
capital2.classList.remove("valid");
capital2.classList.add("invalid");
}
// Validate numbers
var numbers = /[0-9]/g;
if(mypassrp.value.match(numbers)) {
number2.classList.remove("invalid");
number2.classList.add("valid");
} else {
number2.classList.remove("valid");
number2.classList.add("invalid");
}
// Validate Special Char
var specialchar = /[!@#$%^&*+`~=?\|<>/]/g;
if(mypassrp.value.match(specialchar)) {
char2.classList.remove("invalid");
char2.classList.add("valid");
} else {
char2.classList.remove("valid");
char2.classList.add("invalid");
}
// Validate length
if(mypassrp.value.length >= 8) {
length2.classList.remove("invalid");
length2.classList.add("valid");
} else {
length2.classList.remove("valid");
length2.classList.add("invalid");
}
}
var form = document.getElementById("f1");
function handleForm(event) {
if (mypass.value == mypassrp.value)
{
alert("Passwords Match");
}
else{
alert("Password Don't Match");
event.preventDefault(); }
}
form.addEventListener('submit', handleForm);
</script>
</body>
</html>