<input type="radio" id="gender" name="gender" value="male">male
<input type="radio" id="gender" name="gender" value="female">female
function check(){ var ifCheck=document.getElementsByName('gender')[0].checked ||document.getElementsByName('gender')[1].checked?true:false; if(!ifCheck){ alert("您没有选择性别。"); } }