Hiya,
Within a Marketo landing page, that uses a form, I am using the form API's onSubmit() method to make an external POST call to a remote endpoint when the form is submitted. Works well.
When the form is submitted this of course also triggers creation of a lead in the Marketo database. Is there any way to prevent this from happening? So that the form can still be submitted, run the script tied to onSubmit(), but not actually create a new lead in Marketo.
The code I am adding to the LP (with a <script> tag) is below. Anything I can add here that would achieve the above and prevent Marketo lead creation? I thought maybe returning immediately after the API call might do it, but no luck. Thank you!!
Solved! Go to Solution.
The Nation has a Syntax Highlighter for JS. Use Advanced Editor and expand the toolbar.
What you want to do is
form.submittable(false);
Then you can do whatever you want after your separate XHR POST.
Also, are you purposely restricting your LP so it only works on browsers that support async/await and destructuring?
The Nation has a Syntax Highlighter for JS. Use Advanced Editor and expand the toolbar.
What you want to do is
form.submittable(false);
Then you can do whatever you want after your separate XHR POST.
Also, are you purposely restricting your LP so it only works on browsers that support async/await and destructuring?
Thank you Sanford! Will be using the syntax highlighter from now on.
This does exactly what I wanted, perfect solution.
Great question, I'm gonna just use a promise instead of async/await and remove spread syntax when I make it live. Not sure if it'll need IE support yet but will add polyfills if so
I always advise IE compatibility. IE 11 is out there. Unless you have stats that show it never hits your site.