Skip to Content
NFSFU234FormValidation v3 is here — file upload validation, config-driven rules, and more.
v2 (legacy)validateAllCheckbox

validateAllCheckbox

The validateAllCheckbox function validates all checkbox inputs within a specified form. It returns an array of error messages (a nested ErrorMessageInterface) if any checkbox is invalid, or true if all checkboxes are valid.

Works in: HTML5, React JS

ParameterTypeDefaultDescription
formHTMLFormElement | HTMLDivElement | stringundefinedThe form element or its ID containing checkbox inputs.
optionsobject{}Optional settings for validation such as custom error messages.

Usage

Example: Validate All Checkboxes in a Form

const formElement = document.getElementById('myForm'); const result = validateAllCheckbox(formElement, { message: 'You must check all required checkboxes.' }); console.log(result);

See also

Last updated on