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

Validate

The validate function is used to validate a form. When you call this function, it will automatically validate the form based on the specified rules and return the validation result.

Works in: HTML5, React JS

ParameterTypeDefaultDescription
userOptionsHTMLFormElement | HTMLDivElement | string | { form: HTMLFormElement | HTMLDivElement | string; customErrorMessages?: any[] }undefinedOptions for the form validation. Can be a string (ID of the form), an HTMLFormElement, an HTMLDivElement, or an object containing form and custom error messages.
callbackfunctionundefinedOptional callback function to execute after form validation. Receives an error message object as its parameter.

Usage

Option 1.

const myForm = document.getElementById("myForm") nfsfu234FormValidation.validate(form) .then((response) => { const { message, type, data } = response; console.log(response); });

Option 2.

const myForm = document.getElementById("myForm"); nfsfu234FormValidation.validate(myForm, (response) => { const { message, type, data } = response; console.log(response); });

See also

Last updated on