Menu Close

WooCommerce: Disable Keyboard “Enter” on Checkout Page

default

Interesting issue. A client found out that if you push the “enter” on your keyboard while on the WooCommerce Checkout page, the form will be automatically submitted. Ouch! What if the customer wanted to use a different shipping method? What if “enter” is pushed by mistake? So, here’s how you disable it.

1. Install the CSS & JavaScript Toolbox

Just go to the official WordPress Plugin directory here to download it.

Install it.

2. Create a new “code block” and add this code


<script>
jQuery(document).ready(function($) {
$("form").keypress(function(e) {
  //Enter key
  if (e.which == 13) {
    return false;
  }
});
});
</script>

3. Select the checkout page from the right panel

WooCommerce: disable keyboard enter on checkout form
WooCommerce: disable keyboard enter on checkout form

4. Save all changes (CSS & JavaScript Toolbox)

…and the checkout form page won’t submit with the keyboard enter!

View Source
Posted in WooCommerce Tips