html语言如何实现帐号密码登陆?

html-css013

html语言如何实现帐号密码登陆?,第1张

以下代码可以实现静态网页的账号密码登录

<form method="post" action="***" name="form" onsubmit="checkpost()">

<label for="name">用户名:</label>

<input type="text" name="name" id="name" />

<br />

<label for="pw">密码:</label>

<input type="password" name="pw" id="pw" />

<br />

<input type="submit" value="提交" />

</form>

<script>

function checkpost(){

if(document.forms[5].name.value=="用户名"&&document.forms[5].pw.value==" 密码"){

window.location="跳转的地址"

}else{

alert("用户名或密码不正确!")

return false

}

}

</script>

改成这样

<html>

<head>

<title>用户注册</title>

<script language="javascript">

function clicklogin()

{

if(tableLogin.Name.value=="")

{

window.alert("用户名不能为空!")

tableLogin.Name.focus()

return

}

else

{

}

}

</script>

</head>

<body>

<form name="tableLogin">

<table align="center" width="350px">

<th colspan=2>用户注册<th1>

<tr>

<td>用户名</td>

<td><input type="text" name="Name"></td>

</tr>

<tr>

<td>密码</td>

<td><input type="password" name="Pass"></td>

</tr>

<tr>

<td>确认密码</td>

<td><input type="password" name="PassRE"></td>

</tr>

<tr>

<td>性别</td>

<td><input type="radio" name="sex" value=checked>男

<input type="radio" name="sex">女</td>

</tr>

<tr>

<td>爱好</td>

<td><input type="checkbox" name="aihao" value=checked>swim

<input type="checkbox" name="aihao">run

<input type="checkbox" name="aihao">wushu</td>

</tr>

<tr>

<td>出生年月日</td>

<td>年<select>

<script languege="javascript">

for(var i=1950i<=2000i++)

{

document.write("<option>" + i + "</option>")

}

</script>

</select>

月<select>

<script languege="javascript">

for(var i=1i<=12i++)

{

document.write("<option>" + i + "</option>")

}

</script>

</select>

日<select >

<script language="javascript" >

for(i=1i<=31i++)

{

document.write("<option>"+i+"</option>")

}

</script>

</select>

</td>

</tr>

<tr>

<td>照片</td><td><input type="file" name="pic" id="pic" ></td>

</tr>

<tr>

<td colspan=2 align="center"><input type="button" name="login" value="login" onclick="clicklogin()">

<input type="submit" name="submit" value="submit">

<input type="reset" name="reset" value="reset">

<input type="button" onclick=window.close() name="close" value="close"></td>

</tr>

</table>

</form>

</body>

</html>