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

validateRadio

Validates a single radio group by its input name. Returns: string \| boolean \| ErrorMessageInterface

ParameterTypeRequiredDefaultDescription
radioInputField`string \HTMLInputElement`required-
customErrorMessageanyoptional-A custom message to use instead of the default, if the group is invalid.
Usage
Example: Validate a Radio Button Group
// Using with a radio input element const radioElement = document.querySelector('input[name="gender"]'); const result = nfsfu234FormValidation.validateRadio(radioElement, { message: 'Please select a gender.' }); console.log(result); // Using with a radio input element ID const resultById = nfsfu234FormValidation.validateRadio('genderRadioId', { message: 'Please select a gender.' }); console.log(resultById);
Last updated on