<html>
<head>
<meta charset="utf-8" />
<title>登陆界面</title>
<link rel="icon" href="img/login.ico" type="image/x-icon">
<link rel="stylesheet" href="css/login.css" />
<link rel="alternate stylesheet" href="css/night.css" type="text/css" title="dark" />
<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css" /><!-- 引用Font Awesome 图-->
<script>
function checkUser(){
var username = document.getElementById("username").value;//文本框中的值,var是各种变量类型的集合
var pwd = document.getElementById("pwd").value;
var email = document.getElementById("email").value;
var reg = /^([a-zA-Z1-9_-])+([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])/;//邮箱格式包括_-两个符号
if(username == "" && pwd == "" && email == ""){
alert("There is no data");
return;
}
if(username != "123"){
alert("Wrong");
return;//必须要写return跳出
}
if(pwd != "123456"){
alert("Wrong");
return;//必须要写return跳出
}
if(!reg.test(email)){
alert("Wrong");
return;
}
alert("Successful");
window.location.href="turnto.html";//全部通过则定位至链接
}
function switchNightMode(){
var night = document.cookie.replace(/(?:(?:^|.*;\s*)night\s*\=\s*([^;]*).*$)|^.*$/, "$1") || '0';
if(night == '0'){
document.querySelector('link[title="dark"]').disabled = true;
document.querySelector('link[title="dark"]').disabled = false;
document.cookie = "night=1;path=/"
console.log('夜间模式开启');
}else{
document.querySelector('link[title="dark"]').disabled = true;
document.cookie = "night=0;path=/"
console.log('夜间模式关闭');
}
}
</script>
</head>
<body>
<form id="login-box" action="turnto.html" method="get" align="center" onsubmit="return false">
<h1>Login</h1>
<p class="item">
<i class="fa fa-user" style="font-size:24px"></i>
<input name="username" id="username" placeholder="Username" />
</p>
<p class="item">
<i class="fa fa-lock" style="font-size:30px"></i>
<input type="password" name="password" id="pwd" placeholder="Password" />
</p>
<p class="item">
<i class="fa fa-envelope" style="font-size:22px"></i>
<input name="email" id="email" placeholder="E-mail" />
</p>
<input class="btn" type="submit" value="Login" onclick="checkUser()" />
<input class="btn" type="button" value="Night mode" onclick="switchNightMode()" />
</form>
<a href="https://beian.miit.gov.cn" target="_blank" style="position: fixed:bottom;">陕ICP备2020013866号</a>
</body>
</html>
评论0