-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path李玉磊-20281320
96 lines (84 loc) · 2.12 KB
/
李玉磊-20281320
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
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<style>
body {
font-family: Arial, sans-serif;
}
.container {
max-width: 300px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
.container h2 {
text-align: center;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input[type="text"],
.form-group input[type="password"] {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 3px;
}
.form-group .error-message {
color: red;
}
.form-group .success-message {
color: green;
}
.form-group .button-container {
text-align: center;
}
.form-group .button-container button {
padding: 8px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<h2>Login</h2>
<div class="form-group">
<label for="username">Username:</label>
<input type="text" id="username" />
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" id="password" />
</div>
<div class="form-group button-container">
<button onclick="login()">Login</button>
</div>
<div id="message"></div>
</div>
<script>
function login() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
var messageContainer = document.getElementById("message");
// 假设用户名为 "admin",密码为 "password"
var validUsername = "admin";
var validPassword = "password";
if (username === validUsername && password === validPassword) {
messageContainer.innerHTML = '<p class="success-message">Login successful!</p>';
} else {
messageContainer.innerHTML = '<p class="error-message">Invalid username or password.</p>';
}
}
</script>
</body>
</html>