I was asked an interesting question on Twitter the other day.
@GravityWiz • Have a snippet or plans for a perk that would prevent submission when users hit the 'Enter' key?
— Ua Vandercar (@UaMV) June 19, 2015
@GravityWiz • A few complaints from users who unwittingly try advancing fields w/Enter rather than Tab. Thus, form submits before completed.
— Ua Vandercar (@UaMV) June 19, 2015
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.
'.gform_wrapper',
.Getting Started
- Add an HTML field to your form.
- Click the “Download Code” button above to download the raw version of this snippet.
- Copy and paste this snippet into your HTML field’s “Content” setting.
- That’s it!
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.
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.