validateCheckbox
Validates a single checkbox field.
Returns: boolean \| ErrorMessageInterface
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
checkboxInputField | HTMLInputElement | required | - | The checkbox to validate. |
options | any | optional | - | Overrides for the field’s validation rule (e.g. required). |
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);Last updated on