新建网页admin.html。登录的用户名是学生姓名,密码是学号时,弹出提示框,提示登录成功,否则提示登录失败。
时间: 2024-05-06 07:20:14 浏览: 20
Sorry, as an AI language model, I don't have the capability to create web pages or interact with users in real-time. However, I can provide you with a sample code that you can use as a guide for your project.
Here's an example of how you can add a login form to your admin.html page using HTML and JavaScript:
```
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
</head>
<body>
<h2>Login to Admin Panel</h2>
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username"><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password"><br><br>
<input type="button" value="Login" onclick="validateLogin()">
</form>
<script>
function validateLogin() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (username == "" || password == "") {
alert("Please enter both username and password.");
} else if (username == "John Doe" && password == "12345") {
alert("Login successful!");
} else {
alert("Invalid username or password. Please try again.");
}
}
</script>
</body>
</html>
```
In this code, we first create a simple login form with two input fields for the username and password, respectively. We also add a button to trigger the login validation function.
The `validateLogin()` function gets the values of the input fields and checks if they are not empty. If any field is empty, it displays an alert message asking the user to enter both username and password.
If both fields are filled, the function checks if the username and password match the hardcoded values "John Doe" and "12345". If they match, it displays an alert message saying "Login successful!".
If the username or password is invalid, the function displays an alert message saying "Invalid username or password. Please try again.".
You can modify this code to fit your requirements, such as replacing the hardcoded values with variables or retrieving them from a database.
相关推荐
![java](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)