验证具有相同名称的复选框

时间:2016-02-24 08:27:53

标签: javascript html checkbox

如果使用JavaScript检查以下所有复选框,我需要显示错误。

<tr>
  <td>Status</td>
  <td colspan="3">
    <input type="checkbox" name="chk_stat[]" value="single" id="chk_stat">single

    <input type="checkbox" name="chk_stat[]" value="married" id="chk_stat">Married

    <input type="checkbox" name="chk_stat[]" value="divorcee" id="chk_stat">Divorcee

    <input type="checkbox" name="chk_stat[]" value="student" id="chk_stat">Student
  </td>
</tr>

1 个答案:

答案 0 :(得分:1)

您可以使用ORA-29913: error in executing ODCIEXTTABLEOPEN callout ORA-29400: data cartridge error error opening file /orabin/tst/test/XX_LOOKUP_EXT_30723.log 29913. 00000 - "error in executing %s callout" *Cause: The execution of the specified callout caused an error. *Action: Examine the error messages take appropriate action. 选择具有某个给定名称的所有元素,使用伪类document.querySelectorAll选择属性选择器来实现它:

:checked
var checkedCheckboxes = document.querySelectorAll("[name='chk_stat[]']:checked");

if (checkedCheckboxes.length == 0) {
  console.log("No checkbox is checked...");
}

相关问题