If you need to run custom validation, for example an asynchronous check, before an Unbounce form is submitted, you can pause the form's submit action, run your check, and then submit the form yourself.
This modifies your form's built-in submit behavior with custom JavaScript. It is not officially supported, it can break form submission if configured incorrectly, and Unbounce form internals can change over time, so test thoroughly on a published page.
Pause and resume the submit
This community script unbinds the form button's click event, lets you run your own logic, then submits the form. Replace the comment with your validation:
<script>
lp.jQuery().ready(function () {
var id = window.module.lp.form.data.formButtonId;
lp.jQuery("#" + id).unbind("click tap touchstart");
lp.jQuery("#" + id).bind("click tap touchstart", function (e) {
e.preventDefault();
e.stopPropagation();
// Your custom validation here
lp.jQuery("form").submit();
});
});
</script>This handles clicks and taps on the submit button. To also catch the Enter key, you need to rebind the form's keypress event as well. For a general approach to running code at form submission, see How to Run Custom Scripts on Form Submission.