Search.../

onSubmit( )

Runs a callback when a site visitor starts to submit a Wix Form yet before the form is actually submitted and sent to the server.

Note: The WixFormsV2 element is only available in Wix Studio and Editor X.

Syntax

function onSubmit(callback: OnSubmitCallback): void
callback: function OnSubmitCallback(values: FormValues): void

onSubmit Parameters

NAME
TYPE
DESCRIPTION
callback

Callback for the form submission.

Returns

This function does not return anything.

Return Type:

void

OnSubmitCallback Parameters

NAME
TYPE
DESCRIPTION
values
FormValues

Field names and values of a form.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

Getting the form submission values while attempting to submit

Copy Code
1const submit = $w('#form').onSubmit((values) => {
2 console.log('Trying to submit the form with the following values: ', values);
3});
4
5/* Resolves to:
6 *
7 * Trying to submit the form with the following values:
8 * {
9 * "first_name": "John"
10 * "last_name": "Doe",
11 * "email": "john.doe@mail.com"
12 * }
13 *
14*/