Streaming live at 10am (PST)

Custom Actions on Form Submit


I want to perform two custom actions on a form submission. the form has two input fields, one for “seed code” and another for “email”.

There are 6 possible seed codes, and I want to collect the email into Mailchimp.

On submit, the following two things should happen:

  1. Validate email and submit to Mailchimp.
  2. Validate seed code (01, 02, 03, 04, 05, 06) and use that value to redirect to appropriate page e.g. /seed-02, /seed-03, /seed-04 etc.

I have been browsing the forums but haven’t been able to piece together a working solution.

My code at the moment:

(function clickMe() {
  const seed_submit_button = document.getElementById("seed-submit-button");
  seed_submit_button.addEventListener('click', submit);

	function submit() {
  	seed_code_text = document.getElementById("seed-code-text").value;
        window.location.replace(window.location.href + "seed-" + seed_code_text);

My major problem seems to be that the onClick event happens before the form submission in which case the user is redirected to the appropriate page but the email address is not sent to Mailchimp. Is there a way in JS to explicitly trigger the form POST event before I redirect the user?

I tried something like document.getElementById("email-form").submit(); but no luck there.

Thank you!

live site:

Here is my site Read-Only: Webflow - seed-prototype

I was able to get this working with the help of some code from @samliew

Webflow.push(function() {
  $('form').submit(function() {
      setTimeout(function() {
      location.href = window.location.href + "seed-" + $('#seed-code-text').val();
    	}, 100);

Last problem I’m having is with error validation. Mailchimp is good at validating email inputs but this code block executes the redirect even if the user inputs a bad email like or (and it doesn’t push to Mailchimp). If the user inputs a good email address, then Mailchimp does get updated :).

I would like the form to not submit if the user enters a bogus email like but this code block just continues with the redirect.

I tried a simple try/catch block but it seems the error is just printed to the console. MailChimp error: This email cannot be added to this list. Please enter a different email address. I’m not sure how to structure some custom code that executes “if Webflow/Mailchimp JS infos to the console”. Any ideas how to catch this before the redirect?

I explored the message as best I could and it seems like it’s a call by a Webflow script?? See attached.