[thelist] Form Submittal on Enter

.jeff jeff at members.evolt.org
Tue Jan 29 02:29:00 CST 2002


andrew,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Andrew Clover
>
> > perhaps you have a link to a document that contradicts
> > this or provides further information?
>
> [looks]
>
> Hmm, you're right, it looks like my sources are somewhat
> antiquated:
>
>   HTML 2.0 specification, section 8.2.
>
> Look, it was *the* standard when I started writing for
> the web! ;-)
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

not from the way i read it.  i quote:

  "An HTML user agent begins processing a form by
   presenting the document with the fields in their
   initial state. The user is allowed to modify the
   fields, constrained by the field type etc. When
   the user indicates that the form should be
   submitted (using a submit button or image input),
   the form data set is processed according to its
   method, action URI and enctype.

   When there is only one single-line text input field
   in a form, the user agent should accept Enter in
   that field as a request to submit the form."

it looks to me like the use of the "enter" key is only a suggestion and not
a requirement.  additionally, it doesn't actually say anywhere else in the
passage that the "enter" key should *not* be used to submit forms that
contain more than one single-line text input.  in fact, it doesn't address
the use of the "enter" key in any other instances.

i think the "standard" you're thinking of is netscape's interpretation of it
at the time and nn2/nn3's behavior which was to not submit the form without
tabbing to the submit button and pressing the spacebar or "enter" key or
manually clicking it with the mouse.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> IE's behaviour is a bit strange, though, and in a way a
> relic of their extension of this original behaviour.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

if you view the original behavior as correct i suppose.  i've always viewed
the more recent behavior as the correct way of doing it and the old nn2/nn3
way user-hostile.

the only weird thing i find with ie is that sometimes pressing "enter" to
submit won't send the name/value pair of the default submit button (the
first one to appear in the html source).  otherwise its behavior makes sense
to me:

 - no submitting when pressing "enter" while focus is
   on a <select> as the "enter" key has a different
   function with these elements -- selecting the currently
   focused <option>
 - no submitting when pressing "enter" while focus is
   on a <textarea> as the "enter" key has a different
   function with these elements -- adding a carriage return/
   newline.
 - no submitting when pressing "enter" while focus is
   on a radio button or checkbox as the "enter" key has
   a different function with these elements -- checking in
   the case of radio buttons and checking/unchecking in the
   case of checkboxes.

so, that leaves us with text, password, button, and submit inputs.

if you take a quick peek at how forms behave in any windows os (win95+),
you'll notice that the behavior is much the same.  coincidence?  i don't
think so.  microsoft didn't become the most widely used os because it's a
usability/accessibility nightmare.  it became the most widely used os
because it's (for the most part) consistent in it's behavior.  (no, supposed
anti-trust issues don't play into this issue even a millionth as much as you
anti-ms crowd would look the rest of us to think so feck off.  ;p).

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/





More information about the thelist mailing list