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

validateInput

The validateInput function validates a specified input field and returns a promise that resolves to the ErrorMessageInterface.

Works in: HTML5, React JS

ParameterTypeDefaultDescription
inputFieldHTMLInputElement | stringundefinedThe input field to validate or its ID.
optionsobject{}Additional options for validation.
callbackFunctionundefinedCallback function to execute after validation.

Usage

Example: Validate an Email Input Field

// Using with an input element const inputElement = document.querySelector('input[type="email"]'); nfsfu234FormValidation.validateInput(inputElement, { errorType: 'inline', customErrorMessages: { email: { empty : 'Please enter an email address.', formart : 'Please enter a valid email address.' } } }).then(response => { console.log(response); }); // Using with an input element ID nfsfu234FormValidation.validateInput('emailInputId', { errorType: 'modal', customErrorMessages: { email: { empty : 'Please enter an email address.', formart : 'Please enter a valid email address.' } } }).then(response => { console.log(response); });

See also

Last updated on