How to change value of Hubspot Form Through JS

Learn how to pass hidden or non hidden values to Hubspot Input Form Fields. This is done Through JS or jQuery Example.

This is a snippet to show you how to pass a value to a hidden or nonhidden form field on Hubspot Forms

window.addEventListener('message', event => {
   if( === 'hsFormCallback' && === 'onFormReady') {
    document.getElementById("hs-form-iframe-0").contentDocument.querySelector('input[name="form_submission_id"]').value = new Date();