SOLVED

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

Go to solution
Anonymous
Not applicable

Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

If someone is completing a form and presses the "Enter" key, is there any way to prevent the form from treating this the same as clicking the "Submit" button? Or is that a function of the web browser/web browser configuration? The situation is that there is a form with a text box for people to enter comments - and they are pressing "enter", presumably, to add a line break but this action submits the form so their comment is incomplete.

I'm guessing this isn't something configurable on the form - and my workaround would be to move the comments field up above one or more required fields, but would love to know if there's a better way.

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

It's not normal behavior for a Marketo textarea (let alone a browser textarea in general) to interpret "Enter" as "Submit."  Are you using a textarea field, or simply a text field?

On the modern web, letting "Enter" trigger "Submit" in all other kinds of widgets but textareas is the expected action and not something you want to turn off. 

View solution in original post

11 REPLIES 11
SanfordWhiteman
Level 10 - Community Moderator

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

It's not normal behavior for a Marketo textarea (let alone a browser textarea in general) to interpret "Enter" as "Submit."  Are you using a textarea field, or simply a text field?

On the modern web, letting "Enter" trigger "Submit" in all other kinds of widgets but textareas is the expected action and not something you want to turn off. 

Anonymous
Not applicable

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

Hi Sanford - thank you! That was a good question. It's a text field rather than a text area.

SanfordWhiteman
Level 10 - Community Moderator

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

Right, in a text field, "Enter" should submit (at at least ​attempt ​to submit).  Otherwise your form doesn't behave like a standard form, violating Least Astonishment.

Anonymous
Not applicable

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

Hi Sanford,

I think I mis-spoke when I described the field type as "text." That's what it says for the field type when I look at the field in Admin. However:

1) In SFDC where the field originates it's type "Long Text Area"

2) On the Form where the field lives it is type "Text Area"

So now I am confused. Was it incorrect behavior for the "Long Text Area" field to sync down to Marketo as "Text"? What exactly does "Text" mean to Marketo anyway since if you create a field in Marketo the (relevant) options are "String" or "Text Area."?

Can you shed further light on this?

Denise

SanfordWhiteman
Level 10 - Community Moderator

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

Mkto "String" == short string expecting single-line manual entry

Mkto "Text" == long string expecting multi-line manual entry

The reason I add expecting is that actually both types can hold values with newlines in them.  It's harder to get multi-line values into a String -- you need to hack around to do it within the Marketo Admin UI, for example -- but you can still do it.  Because after all, a newline is just a special character.  An HTML <TEXTAREA> on a form makes it easy to create such characters by pressing the Enter key, but that's not the only way to create them.

Anyway, it wasn't wrong at all for the SFDC Long Text Area to come over as Marketo Text.  That's totally right.  What sounds strange still is that when you present this as a <TEXTAREA> on a form, it's still hooking the Enter key as Submit.  What's the URL of your form?  I'll take a look and see what else may be up.

Anonymous
Not applicable

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

Hi Sanford,

Thank you. Here's a form that exhibits the behavior:

http://info.basho.com/Riak-Tech-Talk-Sign-Up.html

Denise

SanfordWhiteman
Level 10 - Community Moderator

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

This is a bug in the ReachForce SmartForms plugin -- it has nothing to do with Marketo.

Precisely, the bug is in this code on line #157 of your document, which I presume is something ReachForce asks you to paste in addition to loading their library:

  var code = e.keyCode || e.which;
  if (code == 13) {
       e.preventDefault();
       sfcc$.SmartFormClick();
       sfcc$.sf_start();
       return false;
  }

This code explicitly traps all carriage returns, which is stupid.  You should talk to them about a workaround or fix.

Anonymous
Not applicable

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

HI Sanford -

It was very generous of you to take the time to look and I would never have figured that out on my own. Thank you very, very much!

Denise

SanfordWhiteman
Level 10 - Community Moderator

Re: Any way to stop a Form from treating pressing the "Enter" key as the same clicking "Submit"?

No problem! Could you mark my answer as Correct to close this out?