-
Notifications
You must be signed in to change notification settings - Fork 0
/
login_limit.html
85 lines (72 loc) · 2.37 KB
/
login_limit.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Validation</title>
<style>
#warning {
color: red;
}
form {
margin: 0 auto;
width: 500px;
border-radius: 20px;
border: 1px solid black;
margin-top: 25vh;
text-align: center;
}
</style>
</head>
<body>
<form onsubmit="return loginValidate()">
<center>
<table cellspacing="15">
<tr>
<td colspan="2" align="center"><h1>Login</h1></td>
</tr>
<tr>
<td>UserName</td>
<td><input type="text" id="username"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" id="password"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" id="login" value="Login"/></td>
</tr>
<tr>
<td colspan="2" align="center"><p id="warning"></p></td>
</tr>
</table>
</center>
</form>
<script>
const username = "admin"
const password = "admin"
let tries = 0
function loginValidate() {
console.log("Click", tries)
const check_username = document.getElementById("username").value
const check_password = document.getElementById("password").value
console.log(check_username)
if(check_username == username && check_password == password) {
document.writeln("Admin Login successful!")
return true
} else {
tries += 1
// Disable button over 3 tries
if(tries == 3) {
const loginBtn = document.getElementById("login")
loginBtn.disabled = true
document.getElementById("warning").innerHTML = "Tries limit exceeded, Try again later :("
}
alert("Incorrect username or password :(")
return false
}
}
</script>
</body>
</html>