无限梦比优斯和赛罗:表单验证 单选按钮是否被选中
来源:百度文库 编辑:高校问答 时间:2024/05/03 05:59:38
<input name="utype" type="radio" value="0"> 个人 <input name="utype" type="radio" value="1">单位
设定两个都未选中,我在提交表单做验证时要判断是否有一个被选中
if (document.Form1.utype.value == "")
{
alert("用户类型不能为空!");
return (false);
}
这样不行,因为单选钮有值,请教我应该怎么办啊!
设定两个都未选中,我在提交表单做验证时要判断是否有一个被选中
if (document.Form1.utype.value == "")
{
alert("用户类型不能为空!");
return (false);
}
这样不行,因为单选钮有值,请教我应该怎么办啊!
<form name="form1" onclik="return aa()">
<input name="utype" type="radio" value="0"> 个人 <input name="utype" type="radio" value="1">单位
<script language = javascript>
function aa()
{
if (document.Form1.utype.checked == false)
{
alert('用户类型不能为空!');
return;
}
}
</script>
把个人或者单位其中的一项加上checked设为默认不就可以了
是不是用单选按纽组啊