How to stop form directing to new window? I'm using Sendpulse for my mailing list and subscriber sign up

I’m having a problem with a form embed from Sendpulse. I am using their ‘simple form embed’ because it’s the cleanest and easiest to style, but the form action keeps sending users via redirect to a Sendpulse page, all the page says is ‘done’, totally unnecessary, but there is no way to turn it off. I want to use the native ‘success’ form elements from Webflow if possible.

Here is the form setup on a test page. simple-form-test


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

Then you need to write some custom code if they support Ajax or choose an alternative product like usebasin.com that can do this.

Hi thanks for taking the time to respond Jeff. The Sendpulse support told me “there is no way to turn off this redirection” with the form, but I figured that can’t be true. I only really know Ajax as Dutch football champions. Do you know any tutorial you could point me toward, please? We do not want to use another subscription service (eg usebasin) for this.

@Max_Wilson - I am not going to try to determine how to leverage the API for you but I do know that there is an integration with Make.com and Zapier.com where either should be able to be used to handle a form submission from Webflow via a webhook and that would keep the native form and behaviors in place. Make has a better free plan but business is business and running one costs money.

“business is business and running one costs money” – thanks for that nugget. We just don’t want to fall into the trap of add-on after add-on, all adding up. Cost-wise, it is difficult to use all these extra services when operating from Argentina. I didn’t ask you to try to determine how to leverage the API for me, I asked if you knew a tutorial you could point me toward [the answer is: ‘no’, understood].

@Max_Wilson - Webflow supports triggering a webhook on form submission via Logic (the built in automation tool) so if your service if choice also supports them then you should be able to accomplish what you want to do without coding. I don’t know if yours does or does not but that is what I would try to determine first. As for costs, Make has a generous free plan. So you might want to determine if you would be under or over their quota and what It could cost.

Thanks again for your response Jeff.

I found an answer to this which solved my problem entirely, and without any additional services. Using JavaScript. Sharing here in case it is useful for the next person with this problem. You can see it working here simple-js-form-test

In the Webflow designer, I have it setup in two embed elements. This is so that I can style the form in the designer, and only the script gets hidden behind the “this script” warning, really useful, worth splitting up the code.

First I’ve build the form, I didn’t need the native form element for this in the end, I just added all the classes for styling from other forms on my site.

In HTML embed one (1):

<!-- SendPulse Simple Subscription Form -->
<form id="sendpulse-form">
    <label>Nombre</label>
    <input type="text" name="name" class="w-input">
    <label>Apellido</label>
    <input type="text" name="surname" class="w-input">
    <label>País</label>
    <input type="text" required name="país" class="w-input">
		<label>Email</label>
    <input type="email" required name="email" class="w-input">
    <input type="hidden" name="sender" value="hola@anchoamagazine.com">
    <button type="submit" class="button w-button">Subscribe</button>
</form>
<!-- SendPulse Simple Subscription Form -->
<div id="response-container"></div>

In embed two, which sends and processes the form, I added bits to include the response from Sendpulse so I can display that as a success message – and then also added a Spanish translation, just swapping the response from Sendpulse into pre-written sentences in Spanish.

HTML embed two (2):

<script>
document.getElementById('sendpulse-form').addEventListener('submit', function (e) {
  e.preventDefault();

  // Get form data
  const formData = new FormData(this);

  // SendPulse form action URL
  const apiUrl = 'https://login.sendpulse.com/forms/simple/u/eyJ1c2VyX2lkIjo3OTI2NjU3LCJhZGRyZXNzX2Jvb2tfaWQiOjUzOTM2MSwibGFuZyI6ImVuIn0=';

  // Make the POST request to SendPulse
  fetch(apiUrl, {
    method: 'POST',
    body: formData,
  })
    .then((response) => {
      if (!response.ok) {
        throw new Error('Network response was not ok');
      }
      return response.text(); // You can change to response.json() if it returns JSON
    })
    .then((data) => {
      // Replace phrases in the response with their translations
      data = data.replace('Confirm subscription', 'Por favor confirma tu suscripción');
      data = data.replace('An email with a link to confirm your subscription was sent to', 'Se envió un correo electrónico con un enlace para confirmar su suscripción a');

      // Create a DOMParser to parse the HTML response
      const parser = new DOMParser();
      const parsedHtml = parser.parseFromString(data, 'text/html');

      // Remove unwanted elements from the parsed HTML
      const unwantedElements = parsedHtml.querySelectorAll('#footer, head');
      unwantedElements.forEach((element) => element.remove());

      // Extract the content you want to display
      const extractedContent = parsedHtml.body.innerHTML;

      // Display the extracted content in the designated container
      const responseContainer = document.getElementById('response-container');
      responseContainer.innerHTML = extractedContent;

      // You can add code here to handle a successful submission
    })
    .catch((error) => {
      console.error('Error:', error);
      // Handle errors here
    });
});

</script>

First the event listener is preventing the default submission. It uses FormData to gather all the data entered in the form fields. It makes an HTTP POST request to SendPulse using the fetch() method. It handles the response from SendPulse in a series of callbacks. The response text is then modified by replacing specific phrases with their translated versions (in this case, English to Spanish). Unwanted elements are removed (e.g., the “Powered by SendPulse” link and content) are removed from the parsed HTML. The remaining content is extracted and displayed within a container.