修改为当用户名为“xie",密码为”123456“,登录到当前根目录的aaa.html页面,反之提示错误
时间: 2024-02-13 12:02:00 浏览: 22
好的,以下是修改后的代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>登录页面</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
body {
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
.container {
max-width: 500px;
margin: 80px auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
h1 {
font-size: 32px;
margin-bottom: 20px;
}
input[type="text"], input[type="password"] {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: none;
border-radius: 3px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
font-size: 16px;
color: #444;
}
input[type="submit"] {
display: block;
width: 100%;
padding: 10px;
margin-top: 20px;
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 3px;
font-size: 16px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<h1>用户登录</h1>
<form id="login-form" method="post" onsubmit="return validateForm()">
<input type="text" name="username" id="username" placeholder="请输入用户名">
<input type="password" name="password" id="password" placeholder="请输入密码">
<input type="submit" value="登录">
</form>
</div>
<script type="text/javascript">
function validateForm() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (username === "xie" && password === "123456") {
window.location.href = "aaa.html";
return true;
} else {
alert("用户名或密码错误,请重新输入!");
return false;
}
}
</script>
</body>
</html>
```
这个登录页面会在用户填写用户名和密码后,通过 JavaScript 对表单进行验证。当用户名为 "xie",密码为 "123456" 时,会跳转到当前根目录下的 aaa.html 页面;否则会弹出提示框提示用户重新输入。
相关推荐
![](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)