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

validateSelect

The validateSelect function validates a specified select input field. It checks if a valid option is selected and returns an ErrorMessageInterface.

Works in: HTML5, React JS

ParameterTypeDefaultDescription
selectFieldHTMLSelectElementundefinedThe select input field to validate.
optionsobject{}Optional settings for validation such as custom error messages.
callbackfunctionundefinedOptional callback function to process the validation result.

Usage

Example: Validate a Select Input

// Using with a select input element const selectElement = document.querySelector('select'); const result = nfsfu234FormValidation.validateSelect(selectElement, { message: 'Please select an option from the dropdown.' }, (response) => { console.log(response); }); console.log(result);

See also

Last updated on