Events & redirects
Success and error events
The client dispatches DOM events on the form element so you can build your own confirmation or error UX:
contact-form:successcontact-form:error
<form data-contact-form id="contact-form">
<!-- fields -->
</form>
<script src="https://script.app.overtureforms.com/contact-form.bundle.js" defer></script>
<script>
window.addEventListener("DOMContentLoaded", function () {
window.ContactFormHandler.initContactForms({
publicKey: "YOUR_PUBLIC_KEY",
formId: "YOUR_FORM_ID"
});
var form = document.getElementById("contact-form");
form.addEventListener("contact-form:success", function () {
alert("Thanks, your message was sent.");
});
form.addEventListener("contact-form:error", function (event) {
console.error("Submission failed", event.detail);
});
});
</script>
For field validation failures (HTTP 422), event.detail.errors maps each
field name to its messages.
On forms with spam protection, a valid submission first
takes the visitor to a short check page hosted by Overture, which sends the
submission and then redirects. contact-form:success fires when the visitor
comes back to the form page, with { referenceId, submissionId } as
event.detail. If they go straight to a success page instead, it doesn't fire
on the form page.
When a form isn't available
Forms built in Overture (rendered with initStandardForm(...) or on Overture's
hosted form pages) answer differently depending on why they can't take a
submission:
| Status | Meaning | What the embed does |
|---|---|---|
404 |
No published form with that slug (never published, unpublished, or archived). | Shows "Form not found." |
410 |
The form exists but isn't accepting submissions right now, because the Overture workspace that owns it doesn't have an active subscription (or has been suspended). | Shows "This form is no longer accepting submissions." and dispatches overture-form:error with { status: 410 } as event.detail. |
Both are permanent from the visitor's point of view, so don't retry them. A
410 clears up on its own once the workspace owner restores their
subscription. If you build your own UI on the overture-form:error event, show
the visitor another way to reach you when event.detail.status is 410.
Controlling the redirect
By default, the redirect after a successful submission is controlled by your form's configuration in the portal. To override it from the page instead, set a redirect attribute on the form:
<form data-contact-form data-contact-form-redirect-uri="/thanks">
<!-- fields -->
</form>
You can also pass redirectUrl to initContactForms(...). Both the attribute
and the option take precedence over the portal-configured redirect.
Redirect URLs get referenceId and submissionId query parameters, so your
success page can show or record the submission's reference.
On forms with spam protection, the redirect happens from Overture's check page once the submission is sent. A success page set on the page goes there directly when it is on the same origin as the form page; one on another origin is followed from the form page after the visitor comes back. See Spam protection.
For safety, only http: and https: redirect URLs are honored — a
javascript: (or other) URL is ignored and never executed in your page.