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.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 thelocale 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.
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 thetranslations parameter.
Client-side validation errors
The following errors may be generated and displayed client-side. They can be contextually overridden using asubmissionErrors 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 asubmissionErrors 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.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 asonFormSubmit, 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 useonBeforeFormSubmit instead.
When performing custom redirects, use onFormSubmitted instead, as this event may prevent submissions being initiated, thus preventing form submissions.