validateAllRadio
The validateAllRadio function validates all radio button groups within a specified form. It returns an array of error messages (a nested ErrorMessageInterface) if any group is invalid, or a single instance of ErrorMessageInterface if all fields are valid.
Works in: HTML5, React JS
| Parameter | Type | Default | Description |
|---|---|---|---|
form | HTMLFormElement | HTMLDivElement | string | undefined | The form element or its ID containing radio button groups. |
customErrorMessage | object | {} | Custom error message to return if validation fails. |
Usage
Example: Validate All Radio Button Groups in a Form
const formElement = document.getElementById('myForm');
const result = nfsfu234FormValidation.validateAllRadio(formElement, {
message: 'Please select an option for all required questions.'
});
console.log(result);See also
Last updated on