<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>简单登陆页面</title>
<script>
function r()
{
var username=document.getElementById("username");
var pass=document.getElementById("password");
if(username.value=="")
{
alert("请输入用户名");
username.focus();
return ;
}
else if(pass.value=="")//----这里是pass.value!!-----
{
alert("请输入密码");
return;
}
else if((pass.value=="123456")&&(username.value=="W"))
{
frm.submit();
}
else
{
alert("登录失败,请检查用户名和密码是否有误!");
return;
}
return true;
}
</script>
</head>
<body>
<form name="frm" action="0.html" method="post"> //-----------
<table >
<tr align=center>
<td>用户名:</td><td><input type="text" name="username" id="username"></td>
</tr>
<tr align=center>
<td>密 码:</td>
<td><input type="password" name="password" id="password"></td></tr>
<tr align=center><td colspan="2">
<input type="button" value="登 录" οnclick="r();"/>
//-----对登录有个点击触发事件,注意这里type不可以用submit,如果是submit不触发就可以提交表单了------
<input type="reset" value="重 置"/></td></tr>
</table>
</form>
</body>
</html>
简单的设置用户名以及密码的登录
最新推荐文章于 2024-06-11 19:11:35 发布