F36: Failure of Success Criterion 3.2.2 due to automatically submitting a form and presenting new content without prior warning when the last field in the form is given a value | WAI | W3C Skip to content

Technique F36:Failure of Success Criterion 3.2.2 due to automatically submitting a form and presenting new content without prior warning when the last field in the form is given a value

About this Technique

This technique relates to 3.2.2: On Input (Failure).

This failure applies to HTML.

Description

Forms are frequently designed so that they submit automatically when the user has filled in all the fields, or when focus leaves the last field. There are two problems with this approach. First is that a disabled user who needs more context may move focus away from the field to the directions on how to fill in the form, or to other text, accidentally submitting the form. The other is that, with some form elements, the value of the field changes as each item is navigated with the keyboard, again accidentally submitting the form. It is better to rely on the standard form behavior of the submit button and enter key.

Examples

Example 1

This failure example submits a form when the user leaves the last field of a three-field telephone number form. The form will submit if the user leaves the field after editing it, even navigating backwards in the tab order. Developers should not use this method to submit a form, and should instead use a submit button, or rely on the form's default behavior of submitting when the user hits enter in a text field.

<form method="get" id="form1">
   <input type="text" name="text1" size="3" maxlength="3"> - 
   <input type="text" name="text2" size="3" maxlength="3"> - 
   <input type="text" name="text3" size="4" maxlength="4" onchange="form1.submit();">
 </form>

Example 2

This is a example that submits a form when the user selects an option from the menu when there is no warning of this behavior in advance. The form will submit as soon as an item from the menu is selected. A user using a keyboard will not be able to navigate past the first item in the menu. Blind users and users with hand tremors can easily make a mistake on which item on the dropdown menu to choose and they are taken to the wrong destination before they can correct it.

<form method="get" id="form2">
   <input type="text" name="text1">
    <select name="select1" onchange="form2.submit();">
      <option>one</option>
      <option>two</option>
      <option>three</option>
      <option>four</option>
    </select>
  </form>

Tests

Procedure

  1. Enter data in all fields on page starting at top.
  2. Enter data in last field and exit from it (tab out of it).
  3. Check whether leaving the last field causes change of context.

Expected Results

  • If check #3 is true, then this failure condition applies and content fails the Success Criterion.
Back to Top