When I using form.create method, The form is loaded but my custom JS code is not working as expected. I can only see 403 forbidden error in my console.
The code assiciated with functions are not triggering .
hbspt.forms.create({
region: “na1”,
portalId: “123456”,
formId: “abcdef-1234…”,
target: “#form-container”,
// Events
onFormReady: function($form) {
alert(‘Form is ready’);
},
onFormSubmit: function($form) {
alert(‘Form is ready to submit’);
},
onFormSubmitted: function($form) {
alert(‘Form is submitted’);
}
});
Hi @JeetuDubey and welcome, we are delighted to have you here!
Thanks for reaching out to the HubSpot Community!
- What is the exact URL where the form is embedded?
- Is your script directly on the page, included via a tag manager, or via another third-party script?
The more info, screenshots (without sensitive/confidential information), and details you can provide, the better the Community can assist.
I’ve found for you the solution from @JohnSmith2314 on this similar post “populating Hubspot Hidden field and 403 error” that might help you.
Now, let’s consult our Top Experts: Hi @GiantFocal, @albertsg and @Anton do you have any insights to share with @JeetuDubey, please?
Have a brilliant day and thanks so much! 
Bérangère
Hi @JeetuDubey,
It might be the case that you are using the “new” HubSpot forms and the code examples might have been used for the “Legacy” forms.
If you are not using “legacy” forms, then take a look at the documentation for using JS with new forms here: