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:

  1. Performs built-in, general validations (such as checking that all email fields contain valid email addresses).
  2. Calls onSubmit(). If the form fields do not pass validation, the submit() function returns the SUBMISSION_ERROR.VALIDATION_FAILED error and the submission of the Wix Form data to the server is aborted.
  3. Sends a request to the server to create a submission.
    If the request is successful:
    1. Calls onSubmitSuccess().
    2. Resets form field values.
    3. The submit() function returns an object with the submitted values.
    If the request fails:
    1. Calls onSubmitFailure().
    2. The submit() function returns an error.

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 })
9
10/* Promise resolves to:
11 *
12 * Form is submitted with the following values
13 * {
14 * "first_name": "John"
15 * "last_name": "Doe",
16 * "email": "john.doe@mail.com"
17 * }
18 *
19*/