Fokus auf den ersten Fehler setzen
Führen Sie Nutzende direkt zu dem, was sie korrigieren müssen.
Fokus auf den ersten Fehler setzen ist eine kostenlose Web Accessibility Academy-Lektion auf CoddyKit. Dies ist Lektion 3 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Web Accessibility Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Web Accessibility Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
Lost After Submit
A user submits, the page shows errors at the top, but focus stays on the button. They have no idea anything failed. 😕
Send Focus to the Problem
On a failed submit, move focus to the first invalid field. The user lands exactly where the fix begins, no hunting required.
Use focus in JS
Find the first failing control and call focus() on it. Now both keyboard and screen reader users start at the right place.
const first = form.querySelector("[aria-invalid='true']");
if (first) first.focus();Read Name, Type, Error
When focus lands there, the screen reader announces the field's name, that it is invalid, and its described error all at once.
First, Not Random
Always target the first error in document order. Jumping to a later field skips problems the user must still address.
Do Not Just Scroll
Scrolling the error into view helps the mouse, but keyboard and screen reader users need real focus moved, not just pixels shifted.
A Summary Box Helps
For many errors, focus an error summary at the top first. List each problem as a link that jumps to its field.
<div tabindex="-1" id="errors">
3 errors found
</div>Make the Summary Focusable
A heading or div is not focusable by default. Add tabindex="-1" so your script can move focus to it programmatically.
Link Errors to Fields
Inside the summary, each item is a link to the field's id. Activating it sends focus straight to the broken input.
<a href="#email">Email is required</a>Avoid Stealing Focus Early
Only move focus in response to the user's submit, never on every keystroke. Yanking focus mid-typing is jarring and unwelcome.
Confirm the Recovery
After the user fixes everything and resubmits, move focus to a success message so they hear that it finally worked.
Quick Check
Where should focus go when a form submit fails?
Recap
On failure, move focus to the first invalid field or a focusable error summary, and to a success message once it passes. ✅
Häufig gestellte Fragen
Ist die Lektion „Fokus auf den ersten Fehler setzen“ kostenlos?
Ja — der vollständige Text von „Fokus auf den ersten Fehler setzen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Web Accessibility Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Web Accessibility Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Fokus auf den ersten Fehler setzen“?
Führen Sie Nutzende direkt zu dem, was sie korrigieren müssen. Du übst Web Accessibility Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Web Accessibility Academy zu starten?
Keine Vorkenntnisse erforderlich. Web Accessibility Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 3 von 4.
Wie lange dauert die Lektion „Fokus auf den ersten Fehler setzen“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Web Accessibility Academy-Lektion Code schreiben und ausführen?
Ja. Jede Web Accessibility Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Fehler mit aria-describedby an Felder binden
- Ungültigen Zustand mit aria-invalid markieren
- Fokus auf den ersten Fehler setzen
- Inline, bei Blur oder beim Absenden: Der Zeitpunkt zählt