1个回答
展开全部
使用JS进行判断
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | < html > < head > < title >判断单选框为必选</ title > < meta charset = "UTF-8" /> </ head > < body > < form name = "from1" > < p >请选择你的性别</ p > < input type = "radio" id = "b" name = "sex" value = "1" >男 < input type = "radio" id = "g" name = "sex" value = "2" >女 < br /> < button type = "button" onclick = "check();" >确定</ button > </ form > < script type = "text/javascript" > function check(){ if(!document.getElementById("b").checked && !document.getElementById("g").checked){ alert("必须选择性别!") return false; } } </ script > </ body > </ html > |
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询