JS验证RadioButton列表或CheckBox列表是否已填写

JS代码:
var Input2=false;
for (i=0;i<document.form1.RadioButtonList2.length;i++
{
    Input2
=Input2||document.form1.RadioButtonList2[i].checked;

if (Input2==false)
{
    alert(
'请选择问题2');
    
return false;
}

HTML代码:
<input id='RadioButtonList2_0' type='radio' name='RadioButtonList2' value='0' /><label for='RadioButtonList2_0'>a111</label><br />
<input id='RadioButtonList2_1' type='radio' name='RadioButtonList2' value='1' /><label for='RadioButtonList2_1'>a222</label><br />
<input id='RadioButtonList2_2' type='radio' name='RadioButtonList2' value='2' /><label for='RadioButtonList2_2'>a333</label><br />
原文地址:https://www.cnblogs.com/wangpei/p/1527967.html