Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-81066

Accessibility: Validate form fields on submit or change, not just tab

XMLWordPrintable

    • MOODLE_404_STABLE
    • MOODLE_404_STABLE
    • MDL-81066-main
    • Hide
      1. Log in as admin.
      2. Go to the Site administration / Courses / Add new course page.
      3. Use the Tab key to continue through the Course full name and Course short name fields without entering any data in them
        • EXPECTED: Error messages should not appear next to the fields.
      4. Click Save and display at the bottom of the form.
        • EXPECTED: The screen scrolls smoothly up to show the Course full name field, which is focused.
        • EXPECTED: Error messages appear next to both fields ('Missing full name', 'Missing short name').
      5. Click Save and display again without fixing the errors.
        • EXPECTED: The screen scrolls up and focuses the first error field again.
      6. Use the Tab key to navigate through both fields.
        • EXPECTED The error messages should not be included in the tab order; the Tab key from a field takes you to the next control which can be activated (the help icon for the next field).
      7. Fix the errors (set both fields to values) and click Save and display.
        • (Existing behaviour) Form should save OK and go back to course page.
      8. Go back into the Settings tab and delete the value from the full name field.
      9. Press the Tab key
        • EXPECTED The 'Missing full name' message should appear immediately, and the field should remain focused.
      10. Press the Tab key again.
        • EXPECTED: User can tab out of field now that the message has appeared
      11. Click Cancel at bottom of form.
        • (Existing behaviour) Form should cancel OK and go back to course page (full name is not changed).
      Show
      Log in as admin. Go to the Site administration / Courses / Add new course page. Use the Tab key to continue through the Course full name and Course short name fields without entering any data in them EXPECTED: Error messages should not appear next to the fields. Click Save and display at the bottom of the form. EXPECTED: The screen scrolls smoothly up to show the Course full name field, which is focused. EXPECTED: Error messages appear next to both fields ('Missing full name', 'Missing short name'). Click Save and display again without fixing the errors. EXPECTED: The screen scrolls up and focuses the first error field again. Use the Tab key to navigate through both fields. EXPECTED The error messages should not be included in the tab order; the Tab key from a field takes you to the next control which can be activated (the help icon for the next field). Fix the errors (set both fields to values) and click Save and display . (Existing behaviour) Form should save OK and go back to course page. Go back into the Settings tab and delete the value from the full name field. Press the Tab key EXPECTED The 'Missing full name' message should appear immediately, and the field should remain focused. Press the Tab key again. EXPECTED: User can tab out of field now that the message has appeared Click Cancel at bottom of form. (Existing behaviour) Form should cancel OK and go back to course page (full name is not changed).

      When form fields have client-side validation (usually for 'required' or 'regex' types), the validation runs when you tab out of the field.

      As originally filed in MDL-80851, this is not very accessible because given that you have just left the field, it's difficult to report an error to screen readers. There is a common behaviour among screenreader users to tab through all form fields to see what is available, and this results in a bunch of extra tab stops and warning messages all through.

      Jun suggested the possibility of changing the validation to run only when the form is submitted. This improves the interface for screenreader and keyboard users (no extra tab stops when completing the form) and is also a bit cleaner for sighted users if you don't fill the form in order (avoiding extra messages appearing). It does have the disadvantage that you don't get feedback quite as fast if you forget a required field, but for a mouse user, you could easily miss out a required field without ever visiting that field, so you won't know about it until you submit anyway (i.e. no real change).

      Another advantage is that this is consistent with server-side validation, which obviously only happens after you submit the form.

      The specific change is that validation occurs on tab key if you change the value of the field (change event), but does not occur if you tab through it without changing it (blur event). In the latter case, validation will still occur when you press the submit button, and the form will scroll back up to show the first affected field.

      Note I have not attempted to use the browser 'required' feature, which causes the browser to prohibit form submission in a similar way itself; this would be a larger change with more details to resolve (browser wouldn't let you submit using 'cancel' button either), and wouldn't handle the other client-side validation that isn't required [regex].

            quen Sam Marshall
            quen Sam Marshall
            Katie Ransom Katie Ransom
            Jun Pataleta Jun Pataleta
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 44 minutes
                3h 44m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.