We wanted to base the message about a failed form submission on the error event, but this also fires when data fields are filled in incorrectly or not at all, not just when something fails during transmission.
Hi @MoKess and welcome, we are so glad to have you here! ![]()
Thanks for reaching out to the HubSpot Community!
To start with, I’d like to share these resources for reference:
- Global form events
- Legacy forms
Could you please share the code you are using so that we can help you the best we can?
The more info, screenshots (without sensitive/confidential information), and details you can provide, the better the Community can assist.
Let’s consult our Top Experts: Hi @nickdeckerdevs1, @zach_threadint and @Anton do you have insights to share with @MoKess, please?
Thanks so much and have a wonderful day!
Bérangère
- New Editor: The “failure event” is over-reporting. It triggers on front-end validation errors (if someone puts a wrong email and a helper text appears) instead of strictly tracking submission failures. In my opinion validation events (wrong user input) should not be part of the submission failure event.
- Old Editor (Code): This version lacks distinct success/failure events, offering only a generic “form submitted” event. Since it returns an HTML response without a status indicator, it likely only tracks successful attempts.
onLoaded((hbspt) => {
try {
hbspt.forms.create({
portalId: portalID,
formId: formId,
target: target,
formInstanceId: instanceId,
locale: locale,
cssClass: ‘hubspot-form’,
onFormSubmitted: (e, data) => {
// e is html raw response
// data is user submission
// we need to know in a deterministic way
// if the submission returned is a success or a failure
submitted.value = true
}
});
} catch {
submitted.value = false
}
})
Hi @MoKess and thanks for sharing this code with us!
So, for the New Editor (hs-form-event:on-submission:failed):
This event fires when “the form submission failed,” but, when looking at the documentation “Global form events”, it’s not clear if front-end validation errors are excluded. If the event triggers on things like an invalid email, even before the form is submitted to the server, that does seem unintended.
This could be a small bug, and it’s a great idea to flag it for HubSpot support!
Regarding the Old Editor (hbspt.forms.create / onFormSubmitted):
You’re right, the legacy embed code’s onFormSubmitted callback only lets you know about successful submissions and doesn’t separate out failures.
Here is what you can do:
If the new editor is reporting failures for simple validation issues, I’d recommend reaching out to HubSpot support.
For legacy forms, there isn’t a built-in way to tell the difference between success and failure in onFormSubmitted.
Hope this helps!
Have a brilliant weekend @MoKess!
Bérangère
This post was created with the assistance of AI tools