onWixFormSubmitted( )
Adds an event handler that runs when a site visitor submits a Wix Form and it is successfully received by the server.
Description
When the site visitor submits a Wix Form, the field values are cleared and the onWixFormSubmitted()
callback runs for the WixForms
element.
The callback to run when the Wix Form is submitted is either the name of the function or a function expression.
The received WixFormSubmittedEvent
object
contains information about the Wix Form that was submitted. The WixFormSubmittedEvent
object is returned by the
callback asynchronously following verification of a successful submission, while the server starts to process the
relevant actions.
onWixFormSubmitted()
provides information and functionality available on the client side:
- The function has access to the field names and field values on the form but does not have access to submission details that exist only on the server, such as the contact ID and the submission time.
- The function performs operations only on the client side, such as displaying a message after submission.
For other Wix Forms events, see:
- The
onWixFormSubmit()
event handler, which sets events that fire when a site visitor submits a Wix Form yet before it is sent to the server. - The
onWixFormSubmittedError()
event handler, which sets events that fire when a site visitor submits a Wix Form and it is not received by the server. - The
onFormSubmit()
event handler, which is called in the Backend section's code, to set events that fire on the backend when a site visitor submits a form.
Syntax
function onWixFormSubmitted(eventHandler: WixFormSubmittedEventHandler): voideventHandler: function WixFormSubmittedEventHandler(event: $w-wixformsubmittedevent-(old-forms-app)): void
onWixFormSubmitted Parameters
NAME
TYPE
DESCRIPTION
The name of the function or the function expression to run when a Wix Form is submitted.
Returns
This function does not return anything.
Return Type:
WixFormSubmittedEventHandler Parameters
NAME
TYPE
DESCRIPTION
Returns
This function does not return anything.
Return Type:
Related Content:
Was this helpful?
An event is fired on a WixForms element when the Wix Form is submitted
1$w("#myWixForm").onWixFormSubmitted( ( {fields} ) => {2 let firstName = fields[0].fieldValue;3 let lastName = fields[1].fieldValue;4 let donation = fields[2].fieldValue;5 let email = fields[3].fieldValue;6 $w('#myText').text = `Thank you, ${firstName} ${lastName}, for your generous donation of ${donation}.`;7});89/* fields array of objects:10 * [11 * {12 * "id" : "inputFirstName",13 * "fieldValue" : "Maria",14 * "fieldName" : "Enter first name"15 * },16 * {17 * "id" : "inputLastName",18 * "fieldValue" : "Santora",19 * "fieldName" : "Enter last name"20 * },21 * {22 * "id" : "inputDonation",23 * "fieldValue" : "1000",24 * "fieldName" : "Enter donation amount"25 * },26 * {27 * "id" : "inputEmail",28 * "fieldValue" : "ms@theCompany",29 * "fieldName" : "Enter email"30 * }31 * ]32 */