大一小白:html+js怎么实现验证固定账号密码跳转另一个界面

�Volcano 2019-05-18 07:00:19

输入账号lcl123 密码123456点击登录 然后跳转到另一个页面
...全文
4011 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
�Volcano 2019-05-19
  • 打赏
  • 举报
回复 3
已解决 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录界面</title>
<link rel="stylesheet" href="登录界面.css">
</head>
<body>
<div class="login">
<h1>Welcome</h1>
<div class="text">
<i class="fa fa-user-o" aria-hidden="true"></i><!-- Font Awesome -->
<input type="text" placeholder="Username" id="name">
</div>
<div class="text">
<i class="fa fa-lock" aria-hidden="true"></i><!-- Font Awesome -->
<input type="password" placeholder="Password" id="pass">
</div>
<button onclick="login()">登录</button>
</div>
</body>
<script type="text/javascript">
function login(){
var username = document.getElementById("name").value;
var password = document.getElementById("pass").value;
if(username=="lcl123" && password=="123456"){
alert("登录成功");
window.location.href = "index.html";
return false;
}
else{
alert("账号或密码错误");
window.location.href= "登录界面.html";
return false;
}
}
</script>
</html>
�Volcano 2019-05-18
  • 打赏
  • 举报
回复
我看了其他帖子 他们都是用form的 我直接用div不可以的吗

61,128

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧