注册(Ajax验证)
<html>
<head>
<script>
function checkage(){
var age=document.getElementById("age").value;
if(age<16||age>24){
alert("输入年龄范围应该为16岁至24岁");
document.getElementById("age").focus();
return false;
}
}
function checkpassword(){
var password = document.getElementById("password").value;
var repassword = document.getElementById("repassword").value;
if(password == ""){
alert("请输入密码");
document.getElementById("password").focus();
return ;
}
if(password != repassword){
alert("输入的密码不一致,请重新输入");
document.getElementById("password").focus();
}}
</script>
</head>
<body background="h.jpg">
<h1 align="center">
<font color="red">注册</font></h1>
<form name="form1" action="">
<table align="center"><tr>
<td>用户名</td>
<td><input type="text" name="username" id="username" onblur="checkuser()"/></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="password" id="password"/></td>
</tr>
<tr>
<td>确认密码</td>
<td><input type="password" name="repassword" id="repassword" onblur="checkpassword()"/></td>
</tr>
<tr>
<td>年龄</td>
<td><input type="text" name="age" id="age" onblur="checkage()"/></td>
</tr>
<tr>
<td><input type="submit" value="注册"/></td>
<td><input type="reset" value="重置"/></td>
</tr>
</table></form>
</body>
</html>