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

Submit

The submit function is used to submit a form. When you call this function, you are going to be automatically validating the form and then it will process for submitting.

Works in: HTML5, React JS

ParameterTypeDefaultDescription
userOptionsHTMLFormElement | HTMLDivElement | string | { form: string | HTMLFormElement | HTMLDivElement, customErrorMessages?: { [key: string]: string } }undefinedOptions for the form submission. 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 submission. Receives an error message object as its parameter.

Usage

Option 1.

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

Option 2.

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

See also

Last updated on