能帮我整理一下格式吗
时间: 2023-07-20 12:18:37 浏览: 40
当然可以,以下是格式整理后的代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login System</title>
</head>
<body>
<h1>Login System</h1>
<form onsubmit="return login()">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<input type="submit" value="Login">
</form>
<script>
function login() {
// 指定账号密码
var username = "admin";
var password = "password";
// 获取用户输入的账号密码
var input_username = document.getElementById("username").value;
var input_password = document.getElementById("password").value;
// 验证账号密码是否正确
if (input_username === username && input_password === password) {
// 登录成功,跳转到主页面并获取登录系统的用户名
window.location.href = "main.html?username=" + username;
return false;
} else {
// 登录失败,弹出提示框
alert("Username or password is incorrect.");
return false;
}
}
</script>
</body>
</html>
```
请注意,我们在 HTML 中使用了缩进和换行来使代码更加易读,并且使用了注释来解释每个部分的功能。在 JavaScript 中,我们使用了空行来分隔不同的代码段,使代码更加清晰。