We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Mar 22, 2018 10:03 PM
I get the following error when I try to manipulate DOM loaded from Hubspot form.
The onFormReady function in hbspt.forms.create requires jQuery. It was not run.
This is the code I use to change input field value:
hbspt.forms.create({
portalId: 'XXXXXX',
formId: 'aa8b5b4a-62ac-461b-a387-XXXXXXXXXXX',
onFormReady($form, ctx){
$('#firstname-6ae5c91f-67cf-40e7-bc53').val('Brian').change();
}
});
Anyone has the same issue?
Apr 9, 2018 4:58 PM
The onFormReady callback requires jQuery to function properly. Some other community users have found some workarounds you might find useful:
Apr 5, 2018 6:53 PM
As @Derek_Gervais is saying, you might not have jQuery loaded on the page. But if you don't need or want jQuery on the page, the offending code is $('#firstname-6ae5c91f-67cf-40e7-bc53')...
This is jQuery syntax.
If you replace it with:
document.getElementById("firstname-6ae5c91f-67cf-40e7-bc53").value = "Brian";
I am not sure what the change event is for, but that will set the value to "Brian"
Full code:
hbspt.forms.create({
portalId: 'XXXXXX',
formId: 'aa8b5b4a-62ac-461b-a387-XXXXXXXXXXX',
onFormReady: function($form, ctx){
document.getElementById("firstname-6ae5c91f-67cf-40e7-bc53").value = "Brian";
}
});
Apr 7, 2018 1:48 AM
I tried nothing under the onFormReady callback function, no matter what it gives me the same error:
shell.js:9 The onFormReady function in hbspt.forms.create requires jQuery. It was not run.
If I remover the onFormReady callback, I don't get error!
Mar 27, 2018 11:51 AM
This might be a basic question to start, but do you have jQuery included on the page in question? Is it loaded before the form script?
Mar 23, 2018 1:14 PM
hbspt.forms.create({
portalId: 'XXXXXX',
formId: 'aa8b5b4a-62ac-461b-a387-XXXXXXXXXXX',
onFormReady: function($form, ctx){
$('#firstname-6ae5c91f-67cf-40e7-bc53').val('Brian').change();
}
});
Mar 23, 2018 1:33 PM
Still getting the same error:
The onFormReady function in hbspt.forms.create requires jQuery. It was not run.