I am having trouble manipulating my hubspot wordpress form from JS/jQuery. I know how to fill the values in other forms, but even though I use .val() and .trigger(‘change’) the fields don’t submit when the form is submitted.
After a few hours, I finally got this working. You have to convert your form to RAW HTML like referred to in this post, because if you don’t hubspot makes the form an iframe, and you can’t manipulate iframes.
Once the code is showing barebones, no css, I would leave one tab open with the css form, and a second tab open with barebones live form. This is so you can copy the styles to make your ugly HTML form look nice later.
You then use this oneliner, and it should work, it has for me.
$(".target").val("").focus().val("DATA TO BE INPUTTED").delay(500).trigger('change').blur()
This code empties the input field, which you NEED to target. Then focuses the browser to it, then fills it with data, then delays 500ms, then triggers a change update, then uses the blur() to unfocus.
I found this solution, as the code literally checks if things have been entered, based on focus and unfocus. That’s when recaptcha runs, and that’s when hubspot verifies the data to be submitted.
There ya go!
Doesn’t it feel good when it finally works ![]()
![]()
Does anyone know any other ways I didn’t think about? If so please comment!