Search...
submit( )
Submits a Wix Form.
Note: The
WixFormsV2
element is only available in Wix Studio and Editor X.
Description
The submit()
function does the following:
- Performs built-in, general validations (such as checking that all email fields contain valid email addresses).
- Calls
onSubmit()
. If the form fields do not pass validation, thesubmit()
function returns theSUBMISSION_ERROR.VALIDATION_FAILED
error and the submission of the Wix Form data to the server is aborted. - Sends a request to the server to create a submission.
If the request is successful:- Calls
onSubmitSuccess()
. - Resets form field values.
- The
submit()
function returns an object with the submitted values.
- Calls
onSubmitFailure()
. - The
submit()
function returns an error.
- Calls
Syntax
function submit(): Promise<FormValues>
submit Parameters
This function does not take any parameters.
Returns
Fulfilled - When submission is successful. Rejected - Error message.
Return Type:
Promise<FormValues>
NAME
TYPE
DESCRIPTION
key:value
string
Key is the form field name, and value is the data submitted for the given field.
Was this helpful?
Submit a form
Copy Code
1$w('#submitButton').onClick(async () => {2 try {3 const formValues = await $w('#form').submit();4 console.log('Form is submitted with the following values', formValues);5 } catch (error) {6 console.log('Submission failed with an error:', error);7 }8 })910/* Promise resolves to:11 *12 * Form is submitted with the following values13 * {14 * "first_name": "John"15 * "last_name": "Doe",16 * "email": "john.doe@mail.com"17 * }18 *19*/