编写HTML注册表单,需求字段:用户名,密码,确认密码,性别(单选),兴趣爱好(多选),城市(下拉列表),个人简介(文本域)
用JavaScript验证这个表单,要求:
1.用户名:字母数字或下划线10位以内,只能以字母开头
2.密码:6-16位任意字符
3.确认密码:和密码保持一致
4.其他项为必填
==================================================
这是我的代码 只做出来个界面 ,没有实现里面的 要求
求大神指点
++++++++++++++++++++++++++++++++++++++++++++++++++
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 注册界面 </TITLE>
<script type="text/javascript">
function fun(){
if(document.getElementById("m").value!=document.getElementById("rem").value){
alert("用户名和密码不一致");
}
}
</script>
</HEAD>
<BODY>
<form action = "" method = "post">
<table border ="1">
<tr>
<td>
用户名
</td>
<td>
<input type = "text" size = "45">
</td>
</tr>
<tr>
<td id="m">密 码</td>
<td>
<input type = "password" size = "45">
</td>
</tr>
<tr>
<td id="rem">确认密码</td>
<td>
<input type = "password" size = "45">
</td>
</tr>
<tr>
<td>性 别</td>
<td>
<input type ="radio" checked = "ture" name = "sex">男
<input type ="radio" name = "sex">女
</td>
</tr>
<tr>
<td>爱 号</td>
<td>
<input type = "checkbox" name = "hoppy" value = "" checked>篮球
<input type = "checkbox" name = "hoppy" value = "" >足球
<input type = "checkbox" name = "hoppy" value = "" >唱歌
</td>
</tr>
<tr>
<td>城 市</td>
<td>
<select>
<option value = "bj">北京</option>
<option value = "sh">上海</option>
<option value = "gz">广州</option>
</select>
</td>
</tr>
<tr>
<td>个人简介</td>
<td>
<textarea cols = "40" rows = "10">不超过200个字</textarea>
</td>
</tr>
<tr>
<td colspan = "2">
<input type = "submit" value = "确认">
<input type = "reset" value = "取消">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
|
|