Enter Key to submit forms - how to stop

Prev Next

There may be times when you want to stop form users from submitting the form when selecting the Enter key - which is the default behaviour of your browser.

This situation arose when a client had produced a multi-page survey form and users were selecting ENTER to proceed to the next page instead of clicking on the Next button.

To achieve this change copy the following Javascript and past into the Form Settings > Appearance field.

</style>
<script>
//place your javascript code here

document.addEventListener("DOMContentLoaded", function () {
  const form = document.querySelector("form");
  form.addEventListener("keydown", function (e) {
    if (e.key === "Enter") {
      e.preventDefault();
    }
  });
});

</script>
<style>