Quantcast
Channel: Snippets Archives - Gravity Wiz
Viewing all articles
Browse latest Browse all 196

Disable Submission when Pressing Enter for Gravity Forms

$
0
0
View this code snippet on GitHub.

I was asked an interesting question on Twitter the other day.

It had not occurred to me that some users would attempt to progress through the forms with the “Enter” key rather than tabbing. I think this is one of those cases where it’s hard to remember how new users interact with forms since we’ve been using them so long.

Disabling submission on enter could be quite frustrating for power users so use this with discretion. If you’re form is targeted towards non-technical users, I think you’ll be safe.

This snippet will only apply to forms created by Gravity Forms. If you’d like to enable this for any type of form, just remove this bit from the snippet: '.gform_wrapper',.

Getting Started

  1. Add an HTML field to your form.
  2. Click the “Download Code” button above to download the raw version of this snippet.
  3. Copy and paste this snippet into your HTML field’s “Content” setting.
  4. That’s it!
gw-gravity-forms-disable-submission-on-enter-html-field

Applying to All Forms

If your theme has a method for including script blocks in the header or footer, you can copy this snippet there.

Otherwise, you’ll need to copy the snippet into an existing script file or create your own. Make sure to remove the <script> tags from the snippet and copy and paste just the inner Javascript into the script file.

@UaMV cooked up a sweet PHP-version of this snippet which can be included in your theme’s functions.php file (or wherever you’re including custom code) and will automatically output the snippet for all forms. View Code Snippet

Was this helpful?

We’d love to know if you use this or have an idea to make it better. Let us know in the comments below.


Viewing all articles
Browse latest Browse all 196

Trending Articles