Zum Hauptinhalt springen
VelinStyle v1.2.0
⌂ Home
  1. Docs
  2. Erste Schritte
  3. Formular-Zusammenfassung

Formular-Zusammenfassung 1.2.0

The <velin-form-summary> Web Komponente turns native constraint validation into an accessible error summary: one focusable panel listing every invalid field, with aria-invalid and aria-describedby wired up per field. English: Form Summary

Reifegrad: Dokumentiert als stabil in VelinStyle 1.2.0. Design Intelligence (Plan / Review / Agent-Meta) ist separat und Beta / Grundlage wo entsprechend angegeben.

Wann verwenden

Wann nicht verwenden

Warum nicht native Validierung?

The browser's own validation bubble shows one error at a time, disappears on its own, cannot be styled, and is inconsistently exposed to assistive technology. On a form with several problems the Nutzer has to discover them one submit at a time.

This Komponente sets novalidate on the form and takes over: on submit it collects every invalid field, renders a persistent summary, and moves Fokus there. Constraint validation itself is unchanged — erforderlich, type, pattern, min, maxlength and custom messages all still apply.

Grundlagen

Place the element inside the form, or anywhere on the Seite with for pointing at the form id.

<form id="signup">
  <velin-form-summary heading="There is a problem with your details"></velin-form-summary>

  <label class="velin-form-label" for="email">Email address</label>
  <input class="velin-form-control" id="email" name="email" type="email" required>

  <button type="submit" class="velin-btn velin-btn--primary">Create account</button>
</form>

Submitting with errors renders a role="alert" panel, focuses it, and announces the number of fields needing attention. Each summary entry Links to its field; activating one moves Fokus straight to the input. Errors clear per field as soon as that field becomes valid, so the summary shrinks as the Nutzer works through it — it never re-flags a field the Nutzer has not submitted yet.

Eigene Meldungen und Container

By Standard the browser's validationMessage is used, which is already localised. Override it per field, and control how the field is named in the summary:

<input id="name" name="name" required
       data-error-message="Enter your full name"
       data-error-label="Name">

Messages are injected as a .velin-field-error element after the field and referenced from aria-describedby. To control placement, supply your own container — the Komponente fills it instead of creating one, and leaves it in the DOM when the error clears:

<input id="email" name="email" type="email" required>
<p class="velin-field-error" data-velin-error-for="email"></p>

Existing aria-describedby hints are preserved: the error id is appended, so a field can point at both its hint and its error.

Attribut

AttributStandardHinweise
forFormular-ID; weglassen, wenn innerhalb des Formulars verschachtelt
headingThere is a problemüberschrift der Zusammenfassung
native-validationKeeps the browser's own bubbles (does not set novalidate)

Per-field attributes: data-error-message, data-error-label, data-error-ignore (skip the field entirely), and data-velin-error-for on a message container. Disabled fields are always skipped, and a radio group is listed once rather than per radio.

JavaScript-API

const summary = document.querySelector('velin-form-summary');

summary.validate();          // returns true when the form is valid
summary.focusFirstError();   // move focus to the first invalid field
summary.clear();             // drop the summary and all field error state

summary.errors;              // [{ field, label, message }]
summary.form;                // the bound form element

Ereignisse

Barrierefreiheit

Vertragsstatus in core/a11y/Komponente-contracts.json: bestanden.