WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Form submission via enter key?

for

From: Paul J. Adam
Date: Nov 6, 2013 1:47PM


Hi Nathalie,

I just don’t see a good reason to go against the standard convention and behavior for all forms in the web. If you press enter inside an input it submits the form. Simple as that, don’t press enter if you don’t want to submit.

It would be easier get browser developers to change their form submission implementation rather than try to get every developer in the world to do something different with their web forms.

I think the answer is: the default behavior is the correct behavior.


Paul J. Adam
Accessibility Evangelist
www.deque.com

On Nov 6, 2013, at 10:54 AM, Nathalie Sequeira < <EMAIL REMOVED> > wrote:

> Well Paul, I could agree on this for a form that has required fields
> that will be checked for completeness, or for a simple search box.
>
> However, in my specific case we are talking of a more complex search
> form that
> a) has no required fields at all, so there will be no validation in the
> way you mean (in fact, if you just send the empty form you will get a
> complete list of all entries listed up by category hierarchy).
> and
> b) has text and checkbox inputs -which when focussed will submit the
> form by default- AND selects -which won't do this by default.
>
> So either way I had an inconsistency of the form's behaviour going on
> there:
> depending on where you were in the form, it would submit itself when
> hitting enter -- or not.
> And it irritated my client, leading them to suggest something I wasn't
> comfortable at all with (i.e. submit via enter anytime).
>
> The longer I think on it, the more I lean towards the view that indeed
> default behaviour doesn't necessarily always equal expected behaviour,
> let alone desirable behaviour.
> There's a submit button, so why not use it, after having selected all
> desired search criteria in an orderly manner?
>
> Please show me where I am wrong if that is the case!
> It is precisely for that reason that I posed this question to the list :)
>
> Cheers,
> Nathalie
>
> Am 06.11.2013 15:52, schrieb Paul J. Adam:
>> If that’s the standard behavior of web forms then why break the norm? And yes like you said when I do my form validation if they press enter key on the first input it would then send their focus to the first invalid input and read the error message automatically. So they could keep pressing ENTER all they want until every field is filled out correctly. Validation should handle any cases of the user accidentally pressing the enter key too soon.
>>
>> On Nov 6, 2013, at 8:45 AM, Corbett, James < <EMAIL REMOVED> > wrote:
>>
>>> Hi:
>>>
>>> Would you really want that to happen? If you had ten edit fields and you allowed the enter key to evoke a submission on the first field, there would be obvious issues. I realize that client side and or server side validation would or could intercept such behaviour but it would be a poor design from the word go....
>>>
>>> Jim
>>>
>>> -----Original Message-----
>>> From: <EMAIL REMOVED> [mailto: <EMAIL REMOVED> ] On Behalf Of Paul J. Adam
>>> Sent: November 6, 2013 9:40 AM
>>> To: WebAIM Discussion List
>>> Subject: Re: [WebAIM] Form submission via enter key?
>>>
>>> The default behavior is to use the ENTER key when focused inside any of the form inputs, this fires the onSubmit event. No reason to change that. What you should not be doing, and a bug I've seen before, is allowing an ENTER key event to submit the form when they are NOT focused inside an input.
>>>
>>> So ENTER should only work to Submit the form when focused inside one of the form's inputs.
>>>
>>> Paul J. Adam
>>> Accessibility Evangelist
>>> www.deque.com
>>>
>>> On Nov 6, 2013, at 12:12 AM, Nathalie Sequeira < <EMAIL REMOVED> > wrote:
>>>
>>>> Thank you all very much for your feedback!
>>>>
>>>> I am quite reassured now that submission via enter key needs to be
>>>> disabled altogether in this case, even where default HTML behaviour
>>>> would allow it.
>>>> Then, the form can only be submitted via the submit button (the exact
>>>> opposite of what the client wants - haha, it's going to be fun selling
>>>> that to them ;D ).
>>>>
>>>> I am also thinking of collapsing the fieldset with instrument checkboxes
>>>> by default (which will also help declutter the form), so one needn't tab
>>>> through all those options to get to the submit button.
>>>>
>>>> Thanks also Detlev for the heads up regarding button states, I will look
>>>> into that too.
>>>>
>>>> Cheers!
>>>> Nathalie
>>>>
>>>> >>>> >>>> >>> >>> >>> >>> >>> >>> >> >> >> >>
>>
>
> --
> Nathalie Sequeira
> ************************
> webseiten mit *n-faktor
> robust*benutzbar*barrierefrei
> www.n-faktor.net
>
> Türingstr. 6
> 6020 Innsbruck
> Mobil: 0650 224 3336
> <EMAIL REMOVED>
>
> > >