Disable Form Submit with the "Enter" Key

</ head>

</ body>

<!-- DISABLE SUBMIT WITH ENTER KEY --> 
<script>
  $(document).ready(function() {
    $(window).keydown(function(event){
      if(event.keyCode == 13) {
        event.preventDefault();
        return false;
      }
    });
  });
</script>

HTML/Embed

Only tabs with a " " have code.
<!-- DISABLE SUBMIT WITH ENTER KEY --> 
<script>
  $(document).ready(function() {
    $(window).keydown(function(event){
      if(event.keyCode == 13) {
        event.preventDefault();
        return false;
      }
    });
  });
</script>
Only tabs with a " " have code.
Only tabs with a " " have code.
Only tabs with a " " have code.
If you have already pasted this code into your project then you can skip this. If you haven't, and it's your first time using CodeCrumbs, then copy this code and navigate to your sites global settings > Custom Code tab > paste it into the <head> (first custom code block). It just needs to exist once.
Author
N/A
Updated on
May 8, 2024

How to use:

Unlock more with PRO

Want to learn how to use this Crumb? Unlock detailed documentation, video tutorials, comments & support!

Upgrade to Pro

Unlock more with PRO

Want to learn how to use this Crumb? Unlock detailed documentation, video tutorials, comments & support!

Upgrade to Pro

Simply paste this code on any page (in the </ body> code section of the page settings) that has a form in which you would like to disable the enter/return key from submitting. if you have multiple forms throughout many different pages then it might be better to paste the code in the global Site Settings > Custom Code > </ body>. This can be very useful for stopping accidental key presses or to use in combination with the "Reveal Submit ButtonWhen Email is Validated" code crumb.

Tutorial Coming Soon!

Check Browser Support

Interactive Table

Simple code to stop or prevent the enter or return key from submitting a form.

Clone Project
Documentation
Author:
Status:
Deprecated
New
Updated
Latest Version:
Built by
Built with
For the best experience

Please switch to desktop to view the content.

Back Home
Thank you! Your submission has been received!
Close Form
Oops! Something went wrong while submitting the form.
Become a Contributor