Skip to main content
Legacy forms allow you to capture information from website visitors, which you can then access throughout HubSpot. You can share links to forms directly with users, submit form data via the API, and embed them on your website pages using the CMS. Below, find reference documentation for forms, including form embed configuration options, internationalization and validation error messages, and form events.
Please note:
If you’re using jQuery to manipulate the values of form inputs (i.e. using val() or prop()), you must trigger a change event using change() or trigger('change') for the change to properly register.

Form embed configuration

When embedding a form, you can include the following customization options in the form embed code.
Please note:
  • Form customization options are only available for forms created in HubSpot that have been set as raw HTML. The HubSpot account must have a Marketing Hub or Content Hub Professional or Enterprise subscription.
  • HubSpot forms should only be loaded using the HubSpot-hosted JavaScript file. Making a copy of the form embed code and self-hosting it is not supported. Any improvements that HubSpot makes to improve security, anti-spam, accessibility, and performance will not propagate to your form if you decide to self-host the HubSpot form embed code.

Embed code callbacks

The form embed code includes event callbacks that you can use to extend form functionality when the events below occur. These are separate from the global form events that you can hook into.

Internationalization

By default, HubSpot provides a set of translated date picker field labels and validation messages for a set of supported languages. You can also add custom languages or override specific error messages and date picker months/days displayed on the form using the translation parameter. To include the default translated strings for a supported language, add the locale parameter to the embed code, followed by one of the languages in the table below.
To add custom languages or override field labels and default translated strings, you can pass language objects into the translations parameter that correspond to the desired locale. For supported locales, you only need to provide the keys and messages you wish to override. For example, the code below configures the form to replace the email field label, required field validation message, and submit button text with custom strings. Learn more about validation below.
In addition to the supported locales, you can register new locale codes in the locale parameter. In this case, make sure to specify messages for all of the keys listed in the table below. Omitted keys will show a “missing translation” message in their place.

Validation messages

HubSpot provides three layers of form validation:
  • Live validation: validation that occurs while a visitor is filling out a form.
  • Client-side validation: validation that occurs after the visitor attempts to submit the form, but before the submission request has been sent to the server.
  • Server-side validation: validation that occurs after form submission.
During each step of validation, HubSpot provides a set of default error messages. These messages can be overridden by using the locale and translation parameters in the form embed code. Below, learn more about the default validation error messages and how to override them depending on when they occur.

Live validation errors

Below are the currently supported live validation field error keys for contextual overriding. These error keys can be specified in the language object of the translations parameter.

Client-side validation errors

The following errors may be generated and displayed client-side. They can be contextually overridden using a submissionErrors object.

Server-side validation errors

The following errors may be generated on the server after a submission request has been sent and displayed client-side when a response is received. They can be contextually overridden using a submissionErrors object.

Form events

Forms allow two ways to bind functionality onto events, including callbacks in the HubSpot form embed code and global form events. Use these events to trigger custom JavaScript. If you need complete control over the styles and actions of your form, it’s recommended that you build your own custom form and submit the data using the Forms API.
Please note:
  • These events are non-blocking, so it’s not possible to prevent a form submission using the onFormSubmit callback.
  • You cannot change form submission data using onBeforeFormSubmit. When using onBeforeFormSubmit, the form is submitted as the event is emitted to the browser. Any listeners hooked to the events do not block the main thread of the form’s execution. For synchronous changes to the form, it is recommended to customize the form embed code instead.

onBeforeFormInit

Called before the form has been inserted into DOM.

onFormReady

Called after the form has been inserted into DOM.

onBeforeFormSubmit

Called at the start of form submission, but before submission has been persisted. Behaves the same as onFormSubmit, but is preferred due to more accurate naming indicating when this event is triggered. When performing custom redirects, use onFormSubmitted instead, as this event may prevent submissions being initiated, thus preventing form submissions.

onFormSubmit

Called at the start of form submission, but before submission has been persisted. Please use onBeforeFormSubmit instead. When performing custom redirects, use onFormSubmitted instead, as this event may prevent submissions being initiated, thus preventing form submissions.

onFormSubmitted

Called after the form has been submitted and the submission has persisted. Recommended for performing custom redirects.
Last modified on March 29, 2026