Success message showing multiple times when placing script in form template | Community
Skip to main content
New Participant
March 4, 2022
Question

Success message showing multiple times when placing script in form template

  • March 4, 2022
  • 1 reply
  • 916 views

I'm having a bizarre issue when attempting to use a JS snippet to display an onSubmit "thank you" message, instead of redirecting the form to another page.

 

I've placed the below script in a hidden rich text field in the form template. The script works, however, the "Success Message" is showing multiple times. Adding this script to the landing page template works as intended, however this won't work in our scenario, because we do want some forms to redirect to other pages, instead of displaying a thank you message.

 

Here's a link to an example page: https://go.arria.com/td_form_success_test.html

 

if (typeof MktoForms2 !== 'undefined') { MktoForms2.whenReady(function (form) { const $form = form.getFormElem() form.onSuccess(values => { const { FirstName } = values const $successMessage = $(` <div class="successMessage"> <p>Thank you ${FirstName}!</p> <p>We will be in touch shortly to talk to you about our product.<p> </div> `); $form.after($successMessage) $form.hide() return false }) }) }

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

SanfordWhiteman
New Participant
March 4, 2022