We use hubspot forms on an external website and popuate hidden fields using javascript. It works 99% of the time, but sometimes the hidden fields are not submitted.
The code:
https://goonlinetools.com/snapshot/code/#em1hiftkwc9628tozkoc8
We use hubspot forms on an external website and popuate hidden fields using javascript. It works 99% of the time, but sometimes the hidden fields are not submitted.
The code:
https://goonlinetools.com/snapshot/code/#em1hiftkwc9628tozkoc8
Is there anything consistently happening during that 1%?
@stefen m @Mike_Eastwood , either of you have any idea what is happening here?
Here’s how we recently solved an issue with hidden fields in non-HubSpot forms:
Your code looks sensible to me.
I find code that works most of the time is more annoying than code that never works!
–Mike
p.s. thanks for the mention @dennisedson
Hello Mike,
I took your advise and changed the field to a text field, made it required and hide it with CSS.
This made me realise that the bug might be related in the Hubspot Forms Script. As you can see in the screenshot, the field “Project PDF URL” is filled in, but it still shows the required error.
I think the bug occurs when you filled the form before and Hubspot remembers the previous filled in values.
Screenshot with field not hidden:
I might have found a solution. Triggering a focus event and then a blur event on the input updates the form validation. So I hope this helps someone in the future:
$('input[name="' + key + '"]')
.val(value)
.change()
.focus()
.blur()
;