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

submit

Validates the whole form (every input, textarea, select, radio, checkbox, and file field), then—if validation succeeds and AJAX is enabled—submits the form using either the supplied AJAX options or the instance’s default AJAX configuration.

The method first resolves the target form from the supplied userOptions (or falls back to the form attached to this instance), validates it, and finally submits it if appropriate.

Validation-only usage is also supported. When AJAX is not enabled, the method simply resolves with the validation result. Returns: Promise<any>

ParameterTypeRequiredDefaultDescription
userOptionsFormConstructorInterfaceoptional-Overrides the form and custom error messages configured on this instance.
callbackobjectoptional-Optional callback invoked with the validation result.
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); });
Last updated on