5新建网页admin.html,页面效果如下图所示。登录的用户名是学生姓名,密码是学号时,弹出提示框,提示登录成功,否则提示登录失败。
时间: 2024-05-09 22:19:04 浏览: 17
很抱歉,作为AI语言模型,我无法提供图形界面展示,但是我可以给你提供相应的HTML和JavaScript代码,希望可以帮到你。
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
h1 {
text-align: center;
margin-top: 50px;
margin-bottom: 30px;
}
form {
width: 300px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.3);
}
label {
display: block;
margin-bottom: 10px;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
margin-bottom: 20px;
box-sizing: border-box;
}
input[type="submit"] {
background-color: #4CAF50;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
margin-top: 10px;
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
</style>
</head>
<body>
<h1>Login Page</h1>
<form id="login-form">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="Login">
</form>
<script type="text/javascript" src="admin.js"></script>
</body>
</html>
```
JavaScript代码:
```javascript
const loginForm = document.getElementById('login-form');
loginForm.addEventListener('submit', function(event) {
event.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
if (username === '学生姓名' && password === '学号') {
alert('登录成功');
} else {
alert('登录失败');
}
});
```
在这段JavaScript代码中,我们首先获取了登录表单元素(id为`login-form`),并为其添加了一个事件监听器,当表单提交时,会执行回调函数。在回调函数中,我们获取了输入框中的用户名和密码,然后进行判断:如果用户名和密码都匹配,就弹出登录成功的提示框,否则弹出登录失败的提示框。