Re-submitting landing page form

  • 25 February 2016
  • 3 replies
  • 12 views

Hi, I’m creating a calculator with Unbounce (at least trying to) thing is, I need to do some validations before the data is submitted as a lead, but when I click the CTA it is automatically submitting the form, so what I did was to unbind the click of the CTA and then use the preventDefault function.

My mission is to do all the validations I need and then when all the validations are clear, to submit the data to unbounce as a lead. Here’s the code.

$(document).ready(function(){

var id=window.module.lp.form.data.formButtonId;
// deletes unbounce-added submit function:

lp.jQuery(’#lp-pom-button-17’).unbind(‘click’);
lp.jQuery(’#lp-pom-button-17’).click(function(e) {

e.preventDefault();
e.stopPropagation();

//HERE GOES ALL MY VALIDATIONS

});

My question is, how can I “re-submit” the landing page form, I’m using
$(’#lp-pom-form-16 form’).unbind(‘submit’).submit();

But it’s not working.

Also tried simply
$(’#lp-pom-form-16 form’).submit();

And still nothing.


3 replies

Userlevel 7
Badge +3

I think you are overdoing it a bit if you are not checking an external database. 

There is a similar thread here in the community that has a lot of examples of scripts you can use, including a recent response from me on how to go about validating an age. 

Take a look when you get a chance.

Best,
Hristian

Hi Hristian, no database involved, I’m trying to validate the form fields, for example that the minimum age is 18 and the maximo is 80…

I ended up working around the form by adding another button, validating everything when that button is clicked, hidding the form CTA and only showing it after everything that I need to validate is validated with the second button.

But if you know way where I can do everything with just 1 button would be nice to learn how.

Userlevel 7
Badge +3

Hi there, 

Are you trying to validate against an external database?

It would be helpful to know what type of validations you are trying to run. 

Best,
Hristian

Reply