forked from mt-bjtu-practical/Front-end-exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path甄梦瑶_20271086.html
86 lines (86 loc) · 2.06 KB
/
甄梦瑶_20271086.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
form {
background-color: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
margin: 50px auto;
width: 400px;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 30px;
}
label {
display: block;
font-size: 18px;
color: #666;
margin-bottom: 10px;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 10px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ccc;
margin-bottom: 20px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
padding: 10px 20px;
font-size: 18px;
border-radius: 5px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
.message {
background-color: #4CAF50;
color: white;
padding: 10px;
border-radius: 5px;
margin-top: 20px;
display: none;
}
</style>
</head>
<body>
<form>
<h1>登录</h1>
<label for="username">用户名</label>
<input type="text" id="username" name="username" placeholder="请输入用户名">
<label for="password">密码</label>
<input type="password" id="password" name="password" placeholder="请输入密码">
<input type="submit" value="登录">
<div class="message">登录成功!</div>
</form>
<script>
const username = "zmy"; // 设置用户名
const password = "123456"; // 设置密码
const form = document.querySelector("form"); // 获取表单元素
const message = document.querySelector(".message"); // 获取提示框元素
form.addEventListener("submit", function(event) {
event.preventDefault(); // 阻止表单提交
const inputUsername = document.getElementById("username").value; // 获取输入的用户名
const inputPassword = document.getElementById("password").value; // 获取输入的密码
if (inputUsername === username && inputPassword === password) { // 判断用户名和密码是否匹配
message.style.display = "block"; // 显示登录成功提示框
}
});
</script>
</body>
</html>