<!DOCTYPE html>
<html>
<head>
<meta charset="bck" />
<title>3.3</title>
<script type="text/javascript">
function verify()
{
var name=document.getElementById("username").value;
var pwd=document.getElementById("pwd").value;
var keycode=name.charCodeAt(0);
if(keycode<65||(keycode>90&&keycode<97)||keycode>122)
document.getElementById("h1").innerText="用户名必须以英文字母开头!";
else if(name.length<6||name.length>18)
document.getElementById("h1").innerText="用户名长度必须为6到18位!";
else
document.getElementById("h1").innerText="";
if(pwd.length<6)
document.getElementById("h2").innerText="密码长度不能小于6位!";
else
document.getElementById("h2").innerText="";
}
</script>
<style>
#one
{
margin: 0 auto;
width: 400px;
height: 30px;
background-color: #0099cc;
color: #fff;
text-align: center;
padding-top: 8px;
font-weight: bold;
}
#two
{
margin: 0 auto;
width: 400px;
height: 280px;
background-color: #00ccff;
}
input[type="text"]
{
margin-top: 30px;
margin-left: 75px;
width: 250px;
height: 38px;
border: 1px solid #CCC;
text-indent: 10px;
color: #6f6f6f;
}
input[type="submit"]
{
width: 255px;
height: 44px;
background-color: #0099cc;
border: 1px solid #CCC;
color: white;
margin-top: 30px;
margin-left: 75px;
}
p
{
font-size: 10px;
color: red;
margin-top: 10px;
margin-left: 75px;
margin-bottom: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="one">注册</div>
<div id="two">
<form>
<input id="username" type="text" name="username" value="请输入您的用户名" onkeydown="verify()"/>
<p id="h1"> </p>
<input id="pwd" style="margin-top: 10px;" type="text" name="pwd" value="请输入您的密码" onkeydown="verify()"/>
<p id="h2"> </p>
<input id="button" type="submit" value="提交"/>
</form>
</div>
</body>
</html>
注册 用户名 密码
最新推荐文章于 2021-07-31 00:59:28 发布