getParameter()来获取“爱好”选项的值
<body>
<form action="zccg.jsp" method="post" name="Form1">
<table width="300" cellspacing="1" border="1">
<div >
<tr height="80"><td align="center">注册页面 </td></tr>
</div>
<td>报名号:
<lable ><input name="t1" type="text" size=12 />(*必填) </lable >
<br />
真实姓名:
<lable ><input name="t2" type="text" size=9 />(*必填)</lable >
<br />
密码:
<lable ><input name="t3" type="text" size=12 />(*必填)</lable >
<br />
学历:
<select>
<option value="1">本科</option>
<option value="2">专科</option>
</select>
<br />
E - mail:
<label ><input name="t4" type="text" size=15 />(*必填)</label >
<br />
爱好:<br />
<input name="s" type="checkbox" value= "xx" >运动
<label ><input name="s" type="checkbox" value="xx" />旅游
<input name="s" type="checkbox" value="xx" />服装
<br />
<input name="s" type="checkbox" value="xx" />阅读
<input name="s" type="checkbox" value="xx" />音乐
<input name="s" type="checkbox" value="xx" />购买
<br />
如何知道本网站: <br />
<input type="radio" value="male" />自己看到
<input type="radio" value="female" />朋友推荐
<br />
备注: <br />
<textarea rows="5" cols="40" align="cnter">
</textarea>
</td>
<tr>
<td align="center"><input type="submit" value="注册" onclick="return yz();"/>
<input type="reset" value="重置"/></td>
</tr>
</form>
</table>
</body>
<%
String z[] = request.getParameterValues("s");
%>
<script laguage="javascript">
function yz(){
var t11=Form1.t1.value;
var t22=Form1.t2.value;
var t33=Form1.t3.value;
var t44=Form1.t4.value;
var x="<%=z%>";
if(t11=="")
{alert("请输入报名号");Form1.t1.value;return false;}
if(t22=="")
{alert("请输入姓名");Form1.t2.value;return false;}
if(t33=="")
{alert("请输入密码");Form1.t3.value;return false;}
if(t44=="")
{alert("请输入邮箱");Form1.t4.value;return false;}
if(x=="")
{alert("请选择至少一个爱好");return false;}
return true;
}
</script>