FORMS - Modifying Input Value on onFormSubmit

CameronJRC
Member

I am able to pull information from the Global Form Event listener. 

 

 

window.addEventListener("message", function(event) {
    if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
        console.log(event.data.data);
    }
});

 

 

I require modifying the data values which isn't effected by direct edits to the event.data.data values and the form isn't obtainable through $('#formid') due to the hubspot form being enclosed within an iFrame. 

 

The API documentation doesn't seem clear on this and previous threads push the $(input=name).val().change() which has the same issue as obtaining the form directly as above. 

 

Has anyone solved this through a documented API or is it neccessary to muddle together a hacked solution?

 

Thanks.

0 Upvotes
1 Reply 1
WendyGoh
HubSpot Employee

Hey @CameronJRC,

 

When looking to modify the form embed code, you would need to set the form as a raw HTML as that the form will render as a raw HTML element on your page as opposed to inside an iframe.

 

More details here: Style your embedded form on external pages.

0 Upvotes