Skip to main content


When you’re building your landing pages in Unbounce, you want the conversion process to be as simple as possible. Nothing too distracting, and you certainly don’t want to scare your audience away with long, time-consuming forms.


We’ve built an easy solution for you because, hey, we’re marketers too! :unbounce:



Introducing Multi-Step Forms! 📈 🎉


No more scary, conversion killing forms!

Follow the steps below to implement this handy script into your landing page and try it for yourself! And, as always, remember to A/B test, and keep us posted on your results!


You can see this in action (built in Unbounce) here:





How to Install in Unbounce




Click Here for Instructions




🚨

This is not an official Unbounce feature. This functionality is based entirely on third party code, and has only been tested in limited applications. Since this isn’t a supported Unbounce feature, our support team will be unable to assist if things go awry. So if you are not comfortable with HTML, Javascript and CSS, please consider consulting an experienced developer.





Step 1.


Create your form in Unbounce.


Step 2.


Create a new button element for your ‘Next’ button and one for your ‘Previous’ button. Keep in mind when positioning these buttons (and your form submission button) that only one field will be shown at a time.


Step 3.


Copy this script and paste it into the Javascripts section of your page with placement ‘Before Body End Tag’:


<script type="text/javascript" src="https://rawgit.com/kimmobrunfeldt/progressbar.js/1.0.0/dist/progressbar.js"></script>

<script>
(function() {
// Update the following IDs with your own button IDs
var backButton = document.getElementById('lp-pom-button-14');
var nextButton = document.getElementById('lp-pom-button-13');
var showProgressBar = false;

var submitButton = document.querySelector('.lp-pom-form .lp-pom-button');
var formContainer = document.querySelector('.lp-element .lp-pom-form');
var currentField = 0;
var allFields = document.getElementsByClassName('lp-pom-form-field');
var errorSpan = document.createElement('span');

for (i = 0; i < allFields.length; i++) {
allFields i].classList.add('hide');
allFields)i].style.top = '0px';
}

backButton.classList.add('hide');
submitButton.classList.add('hide');

allFields 0].classList.remove('hide');

if (allFields<0].querySelector('input')) {
allFields 0].querySelector('input').focus();
}

errorSpan.classList.add('hide');
errorSpan.style.color = 'red';
errorSpan.style.position = 'absolute';
var labelHeight;
if (allFields<0].querySelector('label')) {
labelHeight = allFields 0].querySelector('label').clientHeight;
} else {
labelHeight = 25;
}
errorSpan.style.top = '-' + labelHeight + 'px';
formContainer.appendChild(errorSpan);

if (showProgressBar) {
var progressContainer = document.createElement('div');
progressContainer.id = 'container';
formContainer.appendChild(progressContainer);

var bar = new ProgressBar.Line(container, {
strokeWidth: 4,
easing: 'easeInOut',
duration: 1400,
color: '#FFEA82',
trailColor: '#eee',
trailWidth: 1,
svgStyle: { width: '100%', height: '100%' },
from: { color: '#FFEA82' },
to: { color: '#74D16A' },
text: {
style: {
// Text color.
// Default: same as stroke color (options.color)
color: '#fff',
position: 'absolute',
right: '0',
top: '30px',
padding: 0,
margin: 0,
transform: null,
},
autoStyleContainer: false,
},
step: function(state, bar) {
bar.setText(currentField + 1 + ' of ' + allFields.length);
bar.path.setAttribute('stroke', state.color);
},
});
}

function nextEvent() {
allFields currentField].classList.add('hide');

currentField += 1;
allFields1currentField].classList.remove('hide');
if (allFieldsrcurrentField].querySelector('input')) {
allFields }

if (currentField > 0) {
backButton.classList.remove('hide');
}

if (currentField === allFields.length - 1) {
submitButton.classList.remove('hide');
nextButton.classList.add('hide');
}

updateProgress();
}

function backEvent() {
allFields currentField].classList.add('hide');
submitButton.classList.add('hide');

currentField -= 1;
allFields1currentField].classList.remove('hide');
if (allFieldsrcurrentField].querySelector('input')) {
allFields }
if (currentField === 0) {
backButton.classList.add('hide');
nextButton.classList.remove('hide');
}
if (currentField <= allFields.length - 1) {
nextButton.classList.remove('hide');
}

updateProgress();
}

function currentFieldInvalid() {
var invalidInput = allFieldsicurrentField].querySelector(':invalid');

if (invalidInput) {
errorSpan.textContent = invalidInput.validationMessage;
}

return Boolean(invalidInput);
}

function updateProgress() {
if (showProgressBar) {
var barSize = (currentField + 1) / allFields.length;
bar.animate(barSize); // Number from 0.0 to 1.0
}
}

updateProgress();

nextButton.addEventListener('click', function(e) {
if (currentFieldInvalid()) {
if (allFields/currentField].querySelector('input')) {
allFieldsrcurrentField].querySelector('input').classList.add('hasError');
} else {
allFieldsrcurrentField].childrens1].classList.add('hasError');
}

errorSpan.classList.remove('hide');
e.preventDefault();
} else {
if (allFields/currentField].querySelector('input')) {
allFieldsrcurrentField].querySelector('input').classList.remove('hasError');
} else {
allFieldsrcurrentField].childrens1].classList.remove('hasError');
}

errorSpan.classList.add('hide');
nextEvent();
}
});

backButton.addEventListener('click', backEvent);

submitButton.addEventListener('click', function(e) {
if (currentFieldInvalid()) {
if (allFields/currentField].querySelector('input')) {
allFieldsrcurrentField].querySelector('input').classList.add('hasError');
} else {
allFieldsrcurrentField].childrens1].classList.add('hasError');
}

errorSpan.classList.remove('hide');
e.preventDefault();
} else {
if (allFields/currentField].querySelector('input')) {
allFieldsrcurrentField].querySelector('input').classList.remove('hasError');
} else {
allFieldsrcurrentField].childrens1].classList.remove('hasError');
}

errorSpan.classList.add('hide');
}
});

document.body.addEventListener('keydown', function(e) {
var keyCode = e.keyCode || e.which;

// Enter key
if (keyCode === 13 && currentField < allFields.length - 1) {
if (currentFieldInvalid()) {
if (allFields currentField].querySelector('input')) {
allFields/currentField].querySelector('input').classList.add('hasError');
} else {
allFields/currentField].childrens1].classList.add('hasError');
}

errorSpan.classList.remove('hide');
e.preventDefault();
} else {
if (allFields currentField].querySelector('input')) {
allFields/currentField].querySelector('input').classList.remove('hasError');
} else {
allFields/currentField].childrens1].classList.remove('hasError');
}

errorSpan.classList.add('hide');
e.preventDefault();
nextEvent();
}
} else if (keyCode === 13 && currentField === allFields.length - 1) {
if (currentFieldInvalid()) {
if (allFields currentField].querySelector('input')) {
allFields/currentField].querySelector('input').classList.add('hasError');
} else {
allFields/currentField].childrens1].classList.add('hasError');
}

errorSpan.classList.remove('hide');
e.preventDefault();
} else {
if (allFields currentField].querySelector('input')) {
allFields/currentField].querySelector('input').classList.remove('hasError');
} else {
allFields/currentField].childrens1].classList.remove('hasError');
}

errorSpan.classList.add('hide');
}
}

if (keyCode === 37) {
// Left key
if (currentField > 0) {
backEvent();
}
} else if (keyCode === 39) {
// Right key
if (currentField < allFields.length - 1) {
if (currentFieldInvalid()) {
if (allFields currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.add('hasError');
} else {
allFields currentField].childrens1].classList.add('hasError');
}

errorSpan.classList.remove('hide');
e.preventDefault();
} else {
if (allFields currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.remove('hasError');
} else {
allFields currentField].childrens1].classList.remove('hasError');
}

errorSpan.classList.add('hide');
nextEvent();
}
}
}
});
})();

/**
* Do not remove this section; it allows our team to troubleshoot and track feature adoption.
* TS:0002-03-062
*/
</script>

Step 4.


Update the script with the ID of your ‘Previous’ and ‘Next’ button elements. Tip: Make sure you exclude the ‘#’ in the ID.


Step 5.


Copy this script and paste it into the Stylesheets section of your page:


<style>
#container {
margin-top: -45px;
width: 100%;
height: 8px;
position: relative;
}
.lp-form-errors {
display: none !important;
}
.hasError {
border: 1px solid tomato !important;
box-shadow: 0px 0px 5px 1px tomato !important;
}
.hide {
display: none !important;
}
.lp-pom-form-field,
.lp-pom-button {
-webkit-animation: KEYFRAME-NAME 2s;
-moz-animation: KEYFRAME-NAME 2s;
-o-animation: KEYFRAME-NAME 2s;
animation: KEYFRAME-NAME 2s;
}

@-webkit-keyframes KEYFRAME-NAME {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@-moz-keyframes KEYFRAME-NAME {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@-o-keyframes KEYFRAME-NAME {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes KEYFRAME-NAME {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
</style>

You’re done!


Now sit back and let the conversions roll in… :gif_master:






Can’t see the instructions? Log in or Join the Community to get access immediately. 🚀





Want to take your Unbounce landing pages + Convertables™️ to the next level?

:spinbounce: Check out the Ultimate List of Unbounce Tips, Scripts & Hacks

Hi Caroline,


Thank you for sharing!


I tried implementing it and nothing happens. I had no issues with the original script, but when switching to yours it doesn’t seem to have nay effect. Any idea why?


Thank you!

Elena


I’d love to know if anyone can help. We’ve been using the form and it’s great. But over the last several weeks, we’ve been noticing that some users, primarily on mobile or tablet, are clicking the next button and getting stuck. It’s not doing anything. It happens randomly and we can’t seem to recreate it on any of our devices but we are watching screen record videos of people trying to click the next button with no luck. It usually happens on the first button but can also happen anywhere later in the process. Any thoughts on what we can do to fix this?


Hello @daniestrada11.

Can you share the url of your LP so we can see what’s happening ?

I’m not an expert in JS but me or someone else from the community leaders may find something


@julien_level , Thanks! The page I’ve been working on is: https://talcum.global-settlements.org/clp10/


We haven’t been able to recreate the error, nor has the Unbounce team. It seems to happen randomly, mostly on mobile devices. If anyone is willing to take a look, I’d appreciate it!


Hey @daniestrada11,


Two things come to mind…




  1. It might be possible that the JS for the multi-step form didn’t execute on time and that basically broke the form.




  2. Mobile devices tend to have a higher adoption of ad/content blockers. Since you can’t replicate the issue, it’s quite possible the JS for the multi-step form was blocked all together hence rendering the form inoperable.




Best,

Hristian


Hi, I actually found a different version of this script here Multi-Field, Multi-Step Form 🔥 and it worked for me.


Good luck!


I can added any type of multi-step from on Unbounce If you have any custom multi-step form let’s talk with me i can solve any Survey form with custom javascript


Skype : enayethazari


Hi,


I’m trying to create a multi-step form. I created one successfully but can’t integrate the features I need. The form I was able to create allows one field per step. I was hoping to group fields together that way there won’t be too many fields to fill in. Instead of pressing next 7 times a user would just click next once and click submit to our custom thank you page.


I would like to create a form similar to what Tony Robbins uses. Sample here.


I run a tutoring business so the form would be something like this:

Step 1 - Parent Info

First Name

Last Name

Email

Phone


Go To Step 2 button


Step 2 - Student Info

Student Name

Grade Level

Subject


Schedule Date & Time button


Anyone have any idea how to implement this? I’d like a progress bar to show as well. Any help would be much appreciated.


Thanks.


Hello homeschool,


Try this script:


Thank you for sharing. I got it to work finally but now for some reason, the emails are not being recognized. This is the error I’m getting “Email not present in form submission”. In the meantime, I set Zapier to add emails to Mailchimp since the native Mailchimp + Unbounce integration isn’t working for me. Any ideas on a fix?


Can you share with us the URL of the LP ?


Was able to resolve the issue. Had to add validation to the fields. Thanks for the help.


I have used this script a few times and had no issues. HOWEVER, this one time I am having issues.


Can someone assist? I have a multi-step form on this page https://go.onestopfs.co.nz/first-home-buyers/ - This works fine and appends data to the URL.


the form on my “thank-you” https://go.onestopfs.co.nz/thank-you/ page doesn’t work 😦


Any ideas?


Not sure if this was answered but what if you want to have a couple of fields in step one


Hey @rstarost,


Try this :



Hi,

I’m building a multi step form using the example above but with a few steps containing radio button options that have been stylised as buttons. How do I create an auto-submit onClick feature on those buttons to the next step? So rather than having a NEXT button to go to step 2 or 3 it automatically goes there after selecting an option


@Noah Hello! Do you know which specific changes I would have to add to the code in order to show a progress bar at the top and show a “submit” button? Thank you!


I’m also looking for the same thing here.


Hi @Noah

Is there a way to show the first form question and after clicking next show the rest of the form (instead line by line)?


Awesome tool BTW.


Hi @Idan_Yatziv,


Try the other multi step script, you can do the steps you want : Multi-Field, Multi-Step Form 🔥


Hi @julien_level


Sadly I can not get it working


Hey, I’ve been using this script across all my landing pages but recently I started noticing upon every page load, it jumps to a Typeform I’ve embedded at the bottom of the page. I tried removing line 26-28 as mentioned above but it’s still happening. I’ve also noticed that it only happens on Google Chrome and not on Safari. I’m not much of a coder so it would be great if someone can help me with this. Thanks 🙂

Landing page: https://info.freightclub.com/furniture-freight-shipping


Here is current code I have:


<script type="text/javascript" src="https://rawgit.com/kimmobrunfeldt/progressbar.js/1.0.0/dist/progressbar.js"></script>

<script>
(function() {
// Update the following IDs with your own button IDs
var backButton = document.getElementById('lp-pom-button-324');
var nextButton = document.getElementById('lp-pom-button-323');
var showProgressBar = true;

var submitButton = document.querySelector('.lp-pom-form .lp-pom-button');
var formContainer = document.querySelector('.lp-element .lp-pom-form');
var currentField = 0;
var allFields = document.getElementsByClassName('lp-pom-form-field');
var errorSpan = document.createElement('span');

for (i = 0; i < allFields.length; i++) {
allFields i].classList.add('hide');
allFields i].style.top = '0px';
}

backButton.classList.add('hide');
submitButton.classList.add('hide');

allFields 0].classList.remove('hide');

errorSpan.classList.add('hide');
errorSpan.style.color = 'red';
errorSpan.style.position = 'absolute';
var labelHeight;
if (allFields(0].querySelector('label')) {
labelHeight = allFields 0].querySelector('label').clientHeight;
} else {
labelHeight = 25;
}
errorSpan.style.top = '-' + labelHeight + 'px';
formContainer.appendChild(errorSpan);

if (showProgressBar) {
var progressContainer = document.createElement('div');
progressContainer.id = 'container';
formContainer.appendChild(progressContainer);

var bar = new ProgressBar.Line(container, {
strokeWidth: 4,
easing: 'easeInOut',
duration: 1400,
color: '#FFEA82',
trailColor: '#eee',
trailWidth: 1,
svgStyle: { width: '100%', height: '100%' },
from: { color: '#FFEA82' },
to: { color: '#74D16A' },
text: {
style: {
// Text color.
// Default: same as stroke color (options.color)
color: '#fff',
position: 'absolute',
right: '0',
top: '30px',
padding: 0,
margin: 0,
transform: null,
},
autoStyleContainer: false,
},
step: function(state, bar) {
bar.setText(currentField + 1 + ' of ' + allFields.length);
bar.path.setAttribute('stroke', state.color);
},
});
}

function nextEvent() {
allFields currentField].classList.add('hide');

currentField += 1;
allFields currentField].classList.remove('hide');
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').focus();
}

if (currentField > 0) {
backButton.classList.remove('hide');
}

if (currentField === allFields.length - 1) {
submitButton.classList.remove('hide');
nextButton.classList.add('hide');
}

updateProgress();
}

function backEvent() {
allFields currentField].classList.add('hide');
submitButton.classList.add('hide');

currentField -= 1;
allFields currentField].classList.remove('hide');
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').focus();
}
if (currentField === 0) {
backButton.classList.add('hide');
nextButton.classList.remove('hide');
}
if (currentField <= allFields.length - 1) {
nextButton.classList.remove('hide');
}

updateProgress();
}

function currentFieldInvalid() {
var invalidInput = allFields currentField].querySelector(':invalid');

if (invalidInput) {
errorSpan.textContent = invalidInput.validationMessage;
}

return Boolean(invalidInput);
}

function updateProgress() {
if (showProgressBar) {
var barSize = (currentField + 1) / allFields.length;
bar.animate(barSize); // Number from 0.0 to 1.0
}
}

updateProgress();

nextButton.addEventListener('click', function(e) {
if (currentFieldInvalid()) {
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.add('hasError');
} else {
allFields currentField].children]1].classList.add('hasError');
}

errorSpan.classList.remove('hide');
e.preventDefault();
} else {
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.remove('hasError');
} else {
allFields currentField].children]1].classList.remove('hasError');
}

errorSpan.classList.add('hide');
nextEvent();
}
});

backButton.addEventListener('click', backEvent);

submitButton.addEventListener('click', function(e) {
if (currentFieldInvalid()) {
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.add('hasError');
} else {
allFields currentField].children]1].classList.add('hasError');
}

errorSpan.classList.remove('hide');
e.preventDefault();
} else {
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.remove('hasError');
} else {
allFields currentField].children]1].classList.remove('hasError');
}

errorSpan.classList.add('hide');
}
});

document.body.addEventListener('keydown', function(e) {
var keyCode = e.keyCode || e.which;

// Enter key
if (keyCode === 13 && currentField < allFields.length - 1) {
if (currentFieldInvalid()) {
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.add('hasError');
} else {
allFields currentField].children]1].classList.add('hasError');
}

errorSpan.classList.remove('hide');
e.preventDefault();
} else {
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.remove('hasError');
} else {
allFields currentField].children]1].classList.remove('hasError');
}

errorSpan.classList.add('hide');
e.preventDefault();
nextEvent();
}
} else if (keyCode === 13 && currentField === allFields.length - 1) {
if (currentFieldInvalid()) {
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.add('hasError');
} else {
allFields currentField].children]1].classList.add('hasError');
}

errorSpan.classList.remove('hide');
e.preventDefault();
} else {
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.remove('hasError');
} else {
allFields currentField].children]1].classList.remove('hasError');
}

errorSpan.classList.add('hide');
}
}

if (keyCode === 37) {
// Left key
if (currentField > 0) {
backEvent();
}
} else if (keyCode === 39) {
// Right key
if (currentField < allFields.length - 1) {
if (currentFieldInvalid()) {
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.add('hasError');
} else {
allFields currentField].children]1].classList.add('hasError');
}

errorSpan.classList.remove('hide');
e.preventDefault();
} else {
if (allFields(currentField].querySelector('input')) {
allFields currentField].querySelector('input').classList.remove('hasError');
} else {
allFields currentField].children]1].classList.remove('hasError');
}

errorSpan.classList.add('hide');
nextEvent();
}
}
}
});
})();

/**
* Do not remove this section; it allows our team to troubleshoot and track feature adoption.
* TS:0002-03-062
*/
</script>


Sir how you validate the field.


I tried using this on my landing page, everything worked until I got to a drop-down menu question. Is there something I need to add to the script to allow it to work with dropdown menu formatted questions?


Reply