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

validateCheckbox

The validateCheckbox function validates a specified checkbox input field. It checks if the checkbox is checked and returns an ErrorMessageInterface.

Works in: HTML5, React JS

ParameterTypeDefaultDescription
checkboxInputFieldHTMLInputElementundefinedThe checkbox input field to validate.
optionsobject{}Optional settings for validation such as custom error messages.

Usage

Example: Validate a Checkbox Input

// Using with a checkbox input element const checkboxElement = document.querySelector('input[type="checkbox"]'); const result = nfsfu234FormValidation.validateCheckbox(checkboxElement, { message: 'You must agree to the terms and conditions.' }); console.log(result);

See also

Last updated on