直接上源码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>登录界面</title>
</head>
<script type="text/javascript">
function check(){
var userName =document.getElementById("useerName").value;
var password =document.getElementById("password").value;
var tipUserName=document.getElementById("tipUserName");
var tipUserName=document.getElementById("tipPassword");
if(userName!=""){
if(password!="")
{
if(userName=="admin"){
if(password=="123"){
alert("登陆成功!");
} else{
tipPassword.innerText="密码错误!";
}
}else{
tipUserName.innerText="账号错误!";
}
}else{
tipPassword.innerText="密码不能为空!";
}
}else{
tipUserName.innerText="账号不能为空!";
}
}
</script>
<body align="center">
<br><br><br><br><br><br>
账号:
<input type="text" name="userName" id="userName"oninput="document.getElementById('tipUserName').innerText ='';">
<p id="tipUserword" style="color: red;display: inline;"></p><br>
密码:
<input type="password"name="password" id="password" oninput="document.getElementById('tipPassword').innerText='';"><p id="tipPassword"
style="color:red;display: inline;"></p> <br> <input type="button" id="btnSubmit" onclick="check();" value="提交">
</body>
</html>
他的结果是这样的:
兄弟!别要求太多好吧!应付你的社团作业还是绰绰有余的!!