JS 验证checkbox的代码怎么写
我的checkbox是PHP动态生成的 比如
$arr=array('b','n','a');foreach ($arr as $v) {switch ($v) {case "a": echo "<label><input type=\"checkbox\" name=\"a\" value=\"1\"/> A </label>"; break;case "b": echo "<label><input type=\"checkbox\" name=\"b\" value=\"1\"/> B </label>"; break;case "c": echo "<label><input type=\"checkbox\" name=\"c\" value=\"1\"/> C </label>"; break;}}function checkform(){ if(!document.form.a.checked && !document.form.b.checked && !document.form.c.checked ) { alert("需要选择至少一个类型"); return false; }}