Skip to main content
Inspiring
November 23, 2009
Question

Submit button and Enter button

  • November 23, 2009
  • 2 replies
  • 4074 views

All of my forms have a submit button to process the page. However, a user filled out the form and hit the enter key on the keyboard instead of the submit button on the form,and nothing happened.

Needless to say, he complained,and now the boss said that all enter buttons on the keyboard should function the same as the submit button on the page.

I dont think I have ever done this before. Does this require javascript code to make both function the same, or is there anohter method ?

This topic has been closed for replies.

2 replies

Inspiring
November 23, 2009

Ian's answer is not quite complete.  If the focus is in a dropdown, the enter key will not submit the form.  The OP can determine the relevance.

ilssac
Inspiring
November 23, 2009

Unfortunately the Normal behavior for most browsers is that the enter key will submit a form.

If your form does not do this, you have done something to circumvent the normal browser behavior and that is what would need to be addressed.

Do you have any JavaScript already in play on this form or page?  Is this a basic HTML form or some type of Flash or Ajax form?

trojnfnAuthor
Inspiring
November 23, 2009

ok,I was playing around with my form and the enter button and I think I found the problem, just not the solution.

The submit button is <input type="submit" name="btnSubmit" value="Submit">

The form submits to itself, so when the form is first entered, it checks for the submit  button :

<cfif isDefined("form.btnSubmit")> and if true, processes the form.

So that is why the enter button is disabled.

Now what is the command for the enter button so that I can check for btnSubmit or the enter button ?

ilssac
Inspiring
November 30, 2009

I understand his post. I was asking if the form does have a textarea and the user is in there entering a comment, the form can only be submitted with the submit button, and the enter key becomes a moot point (unless he moves ouf of the textarea to another field).


While the focus is in the text area, the enter will not submit the form, it has another purpose in that control.

To submit the form, the user would have to move the focus.  This can be done with the keyboard by pressing the Tab key.