validateSelect
Validates a single <select> field.
Returns: boolean \| ErrorMessageInterface
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
selectField | HTMLSelectElement | required | - | The select element to validate. |
options | any | required | - | Overrides for the field’s validation rule (e.g. required). |
callback | any | required | - | Optional callback invoked with the 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);Last updated on