
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
function validate(){
var b = true;
var name = document.getElementById("unmae");
var id = document.getElementById("cid");
var pwd = document.getElementById("pwd");
var sex = document.getElementsByName("sex");
var hobby = document.getElementsByName("hobby");
for(var i=0;i<hobby.length;i++){
alert(hobby[i].value);
}
if(name.value==null||name.value==""){
b = false;
alert("姓名不能为空");
}
if(id.value==null||id.value==""){
b = false;
alert("账号不能为空");
}
if(pwd.value==null||pwd.value==""){
b = false;
alert("密码不能为空");
}
if(b==true){
document.getElementById("bt").submit();
}
}
</script>
</head>
<body>
<center>
<form action="#" method="get" id="bt">
<table cellpadding="8px" bgcolor="lightyellow" width="700px" cellspacing="0px">
<tr>
<td align="right" width="30%">名称:</td>
<td><input type="text" name="username" id="unmae"/></td>
</tr>
<tr>
<td align="right" width="30%">账号:</td>
<td><input type="text" name="accid" id="cid"/></td>
</tr>
<tr>
<td align="right" width="30%">密码:</td>
<td><input name="password" type="password" id="pwd"/></td>
</tr>
<tr>
<td align="right" width="30%">性别:</td>
<td>男<input name="sex" type="radio" value="男"/>
女<input name="sex" type="radio" checked="checked" value="女"/>
</td>
</tr>
<tr>
<td align="right" width="30%">兴趣爱好:</td>
<td>学习<input name="hobby" type="checkbox"/>
敲代码<input name="hobby" type="checkbox" checked="checked"/>
打游戏<input name="hobby" type="checkbox" checked="checked"/>
</td>
</tr>
<tr>
<td align="right" width="30%">学校:</td>
<td><select>
<option>清华大学</option>
<option>北京大学</option>
<option>中公教育</option>
<option selected="selected">蓝翔技校</option>
</select>
</td>
</tr>
<tr>
<td align="right" width="30%">头像:</td>
<td><input name="photo" type="file"/></td>
</tr>
<tr>
<td align="right" width="30%">自我介绍:</td>
<td>
<textarea cols="50" rows="13"></textarea>
</td>
</tr>
<tr>
<td align="right" width="30%">注册时间:</td>
<td><input type="date" name="date"/></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" onclick="validate()"/>
<input type="reset" />
</td>
</tr>
</table>
</form>
</center>
</body>
</html>