不能检测到单选按钮是否被选中
<script language="javascript">function yanzheng()
{
if (document.tijiao.user_name.value=="")
{
window.alert("请填写姓名");
document.tijiao.user_name.focus();
return (false);
}
if (document.tijiao.radio.value=="")
{
window.alert("请选择性别");
document.tijiao.radio.focus();
return (false);
}
if (document.tijiao.age.value=="")
{
window.alert("请输入年龄");
document.tijiao.age.focus();
return (false);
}
}
</script>
<form id="form1" name="tijiao" method="post" action="user.asp?da=da1" onsubmit="return yanzheng();">
<label>姓名:
<input type="text" name="user_name" />
</label>
<label><br />
性别: </label>
<label>
<input type="radio" name="xingbie" value="男" />
男
<input type="radio" name="xingbie" value="女" />
女
<br />
年龄:
<input name="age" type="text" id="age" />
</label>
<p>
<label>
<input type="submit" name="Submit" value="提交" />
</label>
<label>
<input type="reset" name="Submit2" value="重置" />
</label>
</p>
</form>