<dl>
<dt>1.选择一个偶数</dt>
<dd>
<label><input type="radio" name="radio" value="1">A.1</label>
<label><input type="radio" name="radio" value="3">A.3</label>
<label><input type="radio" name="radio" value="2">A.2</label>
<label><input type="radio" name="radio" value="5">A.5</label>
</dd>
<a href="javascript:;" class="formBtn">提交</a>
</dl>
<script type="text/javascript">
document.getElementsByClassName('formBtn')[0].onclick = function(){
var radio = document.getElementsByName('radio'),vals=null;
for(var i=0;i<radio.length;i++){
if(radio[i].checked){
vals=radio[i].value;
(radio[i].value%2==0)? alert('正确'):alert('错误');
}
}
if(vals==null){
alert('请选择答案后再提交')
}
}
</script>
温馨提示:内容为网友见解,仅供参考