Thank you message after lightbox form submission
Hi,
I have a use case where I need to show a pop-up form in a Marketo hosted landing page followed by a thank you message on successful form submission. I'm using Marketo lightbox embed code for the same. After successful form submission, a user should be able to see a thank you message in the same pop-up. For this, I am using the below script but with this script the thank you message displays for a moment (for even less than a second) and then the pop-up disappears.
<script>
MktoForms2.whenReady(function(form) {
var formEl = form.getFormElem()[0];
form.onSuccess(function(vals, thankYouURL) {
var thanksEl = document.createElement('DIV');
thanksEl.innerHTML = "<div class='popUp'><h2 style='color: #000; font-size: 38px; font-weight: 300;'>Thank you! </h2><p style='color: #fff; font-size: 16px; text-align: center;'>Thank you for contacting us. We'll reach out to you as soon as possible!</p></div>";
formEl.parentNode.replaceChild(thanksEl, formEl);
return false;
});
});
</script>
I also tried setTimeout function after replacing the form element with the thanksE1 element but no luck.
Has anyone ran through the same issue before? Appreciate any help on the same.
Best Regards,
Aditi