onFormSubmit mobile issue

New Contributor

Hello dear developers,

we use a custom code on the base of Hubspot Formular. It uses standard function from Forms API "onFormSubmit" - calculates form fields and displays the result as the form is being sent:

 onFormSubmit: function($form){
   ga('send', 'event', 'Landing Pages', 'Form Submit', 'KIWI Rechner');

function calculateResult(){
// get the form data
var feld1 = $('input[name="rechner_smart_entry"]').val();
	var feld2 = $('input[name="rechner_smart_lock"]').val();
var feld3 = $('input[name="rechner_andere_tueren"]').val();

// calculate the result
result = (feld1 * 634.683 + feld2 * 47.33 + feld3 * 164.83) * 10;  
result = result.toLocaleString( navigator.language ,{maximumFractionDigits:0});

// write the result into the hidden result field in the form ...

// ... and also display it on the page
document.getElementById("resultContainer").innerHTML = result + ' €';
  document.getElementById("rechner-ergebnis").style.display = "block"; 
}, 2000);


The problem is that it works perfect on desktop, but wrong at the mobile >> the result is being shown after user pushes the submit button but form is not sent and we lose a lead.

Do you have any idea how to make it right?

Thank you in advance!

1 Reply 1
HubSpot Employee

Welcome, @pavel!

Nothing is jumping out to me from the code alone.

Would you mind sharing your Hub ID and a link to the form's landing page? If it's not too disruptive to your reps, I'd like to run some tests.

Isaac Takushi

Alumnus, HubSpot Developer Support