JS注册页面全代码
性别:男女。确认密码:
给你一个写好的,你参考一下:
<html>
<head>
<title></title>
<script type="text/javascript">
function init(){
document.form1.username.focus();
}
function blu(){
var space=document.form1.username.value;
if(space==""){
var sp=document.getelementbyid("sp").innerhtmL="用户不能为空";
}
else {
document.getelementbyid("sp").innerhtmL="";
}
}
function funpsd(){
var psd=document.form1.psd.value
if(psd==""){
document.getelementbyid("sp1").innerhtmL="密码不能为空";
}
else if(psd.length<6 || psd.length>15){
document.getelementbyid("sp1").innerhtmL="密码不能小于6位或不能大于15位";
}
else if(isnan(psd)){
document.getelementbyid("sp1").innerhtmL="密码必须是数字";
}
else {
document.getelementbyid("sp1").innerhtmL="";
}
}
function funcpsd(){
var psd1=document.form1.psd.value;
var psd2=document.form1.cpsd.value; //变量赋值在前
if(psd1!=psd2){
document.getelementbyid("sp2").innerhtmL="密码不一致,请重新输入";
document.form1.psd.select();
//psd2="" //把变量清空,但document.form1.cpsd.value还是原来的值,并没有清空document.form1.cpsd.value的值
document.form1.cpsd.value="";
}
else{
document.getelementbyid("sp2").innerhtmL="";
}
}
function funqq(){
var qq=document.form1.qq.value;
if(isnan(qq)){
document.getelementbyid("sp3").innerhtmL="qq必须是数字";
}
else if(qq.length<=7 || qq.length>=12){
document.getelementbyid("sp3").innerhtmL="qq不能小于8位或大于12位";
}
else {
document.getelementbyid("sp3").innerhtmL="";
}
}
</script>
</head>
<body οnlοad="init();">
<form name="form1" method="post" action="">
<div>
<label for="username">
用户:<input type="text" name="username" id="username" οnblur="blu();" value="" /><span id="sp"></span>
</label>
</div>
<div>
<label for="psd1">
密码:<input type="password" name="psd" id="psd1" οnblur="funpsd();" value="" /><span id="sp1"></span>
</label>
</div>
<div>
<label for="cpsd1">
确认密码:<input type="password" name="cpsd" id="cpsd1" οnblur="funcpsd();" value="" /><span id="sp2"></span>
</label>
</div>
<div>
<label for="sex">
性别:<input type="radio" name="sex" value="男" checked="checked">男<input type="radio" name="sex" value="女">女
</label>
</div>
<div>
年龄:
<select name="sel">
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
</select>
</div>
<div>
QQ:<input type="text" value="" name="qq" οnblur="funqq();" /><span id="sp3"></span>
</div>
<div>
<input type="submit" value="提交" />
<input type="reset" value="重置" />
</div>
</form>
</body>
</html>
更多推荐
所有评论(0)