<!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=gb2312" />
<title>注册</title>
<style type="text/css">
*{ font-size:12px;}/* 默认所有元素字体为12PX*/
#login{ margin:0px auto; width:600px; height:auto; background:#999999;}
.td1{ text-align:right;}
.input{ width:150px;height:15px; }
.textarea{width:220px;height:250px}
</style>
<script type="text/javascript">
//document.getElementById("name").focus();
//验证用户名的方法
function checkName(){
var name = document.getElementById("name").value;
var reg=/^[a-zA-Z]{1}\w{5,15}$/; //字母开头6-15位的字符串
document.getElementById("name").style.border="1px solid #cff";
if(name==""||name==null){
divName.style.color="red"
divName.innerHTML="×用户名不能为空";
return false;
}else{
if(reg.test(name)){
divName.style.color="#00FF00"
divName.innerHTML="√可用";
return true;
}else{
divName.style.color="red"
divName.innerHTML="×用户名格式不正确";
return false;
}
}
}
//验证密码
function checkPwd(){
var pwd = document.getElementById("pwd").value;
var reg=/^[a-zA-Z]{1}.{5,14}$/; //首字母开头非空的6-15位的字符串
document.getElementById("pwd").style.border="1px solid #cff";
if(pwd==""||pwd==null){
divPwd.style.color="red"
divPwd.innerHTML="×密码不能为空";
return false;
}else{
if(reg.test(pwd)){
divPwd.style.color="#00FF00"
divPwd.innerHTML="√可用";
return true;
}else{
divPwd.style.color="red"
divPwd.innerHTML="×密码格式不正确";
return false;
}
}
}
//确认密码
function checkPwd2(){
var pwd = document.getElementById("pwd").value;
var pwd2 = document.getElementById("pwd2").value;
document.getElementById("pwd2").style.border="1px solid #cff";
if(pwd2==""||pwd2==null){
divPwd_2.style.color="red"
divPwd_2.innerHTML="×密码不能为空";
return false;
}else{
if(pwd2==pwd){
divPwd_2.style.color="#00FF00"
divPwd_2.innerHTML="√可用";
return true;
}else{
divPwd_2.style.color="red"
divPwd_2.innerHTML="×两次输入密码不一样";
return false;
}
}
}
//验证是否提交
function check(){
if(checkName()&&checkPwd()&&checkPwd2()){
event.returnValue = true;
//return true;
}else{
alert("你输入的信息不正确!")
event.returnValue = false;
//return false;
}
}
//用户名提示信息
function tipName(){
document.getElementById("name").style.border="1px solid #c00";
divName.style.color="#000000"
divName.innerHTML="请输入6-15位字母开头的字母数字下划线组合";
}
//密码格式提示信息
function tipPwd(){
document.getElementById("pwd").style.border="1px solid #c00";
divPwd.style.color="#000000"
divPwd.innerHTML="请输入首字母开头非空的6-15位的字符组合"
}
//确认密码提示信息
function tipPwd2(){
document.getElementById("pwd2").style.border="1px solid #c00";
divPwd_2.style.color="#000000"
divPwd_2.innerHTML="为确保密码准确性,请再次输入密码"
}
</script>
</head>
<body>
<div id="login">
<form action="a.html" onsubmit="check()" method="post">
<table>
<tr>
<td class="td1">用户名:</td>
<td><input type="text" id="name" onblur="checkName()" onfocus="tipName()" class="input" maxlength="15" /></td>
<td><div id="divName"></div></td>
</tr>
<tr>
<td class="td1">密 码:</td>
<td><input type="password" id="pwd" onblur="checkPwd()" onfocus="tipPwd()" class="input" maxlength="15" ></td>
<td><div id="divPwd"></div></td>
</tr>
<tr>
<td class="td1">确认密码:</td>
<td><input type="password" class="input" onblur="checkPwd2()" onfocus="tipPwd2()" maxlength="15" id="pwd2" ></td>
<td><div id="divPwd_2"></div></td>
</tr>
<tr>
<td class="td1">性 别:</td>
<td><input type="radio" id="sex1" name="sex" vlaue="1">男<input type="radio" id="sex2" name="sex" vlaue="0">女</td>
<td><div id="divSex"><div></td>
</tr> <tr>
<td class="td1">兴 趣:</td>
<td colspan="2"><input type="checkbox" value="game" name="hobby1" />游戏
<input type="checkbox" value="sports" name="hobby2" />体育
<input type="checkbox" value="reading" name="hobby3" />看书
<input type="checkbox" value="music" name="hobby4" />音乐
</td>
</tr>
<tr>
<td class="td1">城 市:</td>
<td colspan="2">
<select id="city">
<option>请选择</option>
<option value="1">北京</option>
<option value="2">上海</option>
<option value="3">天津</option>
<option value="4">福建</option>
<option value="5">广东</option>
</select>
</td>
<td><div id="divCity"></div></td>
</tr>
<tr>
<td class="td1">个人简介:</td>
<td colspan="2"></td>
</tr>
<tr>
<td></td>
<td colspan="2"><textarea class="textarea"></textarea></td>
</tr>
<tr>
<td colspan="3" style="text-align:center"><input type="submit" onclick="" value="提交"> <input type="reset" value="重置"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
|