FormsInteractive Form Validation
A contact form with per-field rules, messages tied to each field and an error summary that links to the first problem, using XON.
Text, email, number, search and multi-line fields with a label, a hint and an error line tied to the field, switched on by the browser's own checks.
Checked on 3 December 2026 in Chrome 143.0.7499.169: 12 automated checks. What the checks are
<section class="ti" aria-labelledby="ti-title">
<h2 class="ti__title" id="ti-title">Text inputs</h2>
<p class="ti__lede">Every field has a visible label, a hint and a message that the browser’s own checks switch on. No script.</p>
<div class="ti__grid">
<div class="ti__field">
<label class="ti__label" for="ti-name">Display name</label>
<input class="ti__input" id="ti-name" type="text" required minlength="2" maxlength="30" autocomplete="off" aria-describedby="ti-name-hint ti-name-error">
<p class="ti__hint" id="ti-name-hint">Two to 30 characters.</p>
<p class="ti__msg ti__msg--error" id="ti-name-error"><span aria-hidden="true">!</span> Enter at least two characters.</p>
</div>
<div class="ti__field">
<label class="ti__label" for="ti-email">Email address</label>
<input class="ti__input" id="ti-email" type="email" required autocomplete="off" aria-describedby="ti-email-hint ti-email-error ti-email-ok">
<p class="ti__hint" id="ti-email-hint">Use the form name@example.com.</p>
<p class="ti__msg ti__msg--error" id="ti-email-error"><span aria-hidden="true">!</span> That does not look like an email address.</p>
<p class="ti__msg ti__msg--ok" id="ti-email-ok"><span aria-hidden="true">✓</span> Looks right.</p>
</div>
<div class="ti__field">
<label class="ti__label" for="ti-amount">Weight</label>
<div class="ti__group">
<input class="ti__input ti__input--group" id="ti-amount" type="number" inputmode="decimal" min="1" max="500" step="1" placeholder="25" aria-describedby="ti-amount-hint ti-amount-error">
<span class="ti__affix" aria-hidden="true">kg</span>
</div>
<p class="ti__hint" id="ti-amount-hint">A whole number of kilograms, 1 to 500.</p>
<p class="ti__msg ti__msg--error" id="ti-amount-error"><span aria-hidden="true">!</span> Choose a number from 1 to 500.</p>
</div>
<div class="ti__field">
<label class="ti__label" for="ti-search">Search</label>
<div class="ti__group">
<svg class="ti__icon" viewBox="0 0 20 20" width="18" height="18" aria-hidden="true" focusable="false"><circle cx="8.5" cy="8.5" r="5.5" fill="none" stroke="currentColor" stroke-width="2"/><path d="M13 13l4.5 4.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>
<input class="ti__input ti__input--search" id="ti-search" type="search" placeholder="Search the notes" aria-describedby="ti-search-hint">
</div>
<p class="ti__hint" id="ti-search-hint">Nothing is searched in this example.</p>
</div>
<div class="ti__field ti__field--wide">
<label class="ti__label" for="ti-note">Note</label>
<textarea class="ti__input ti__input--area" id="ti-note" rows="3" maxlength="200" aria-describedby="ti-note-hint"></textarea>
<p class="ti__hint" id="ti-note-hint">Up to 200 characters.</p>
</div>
<div class="ti__field">
<label class="ti__label" for="ti-locked">Locked field</label>
<input class="ti__input" id="ti-locked" type="text" value="Cannot be changed" disabled aria-describedby="ti-locked-hint">
<p class="ti__hint" id="ti-locked-hint">Disabled fields are skipped by the keyboard.</p>
</div>
<div class="ti__field">
<label class="ti__label" for="ti-ref">Reference</label>
<input class="ti__input" id="ti-ref" type="text" value="REF-2041" readonly aria-describedby="ti-ref-hint">
<p class="ti__hint" id="ti-ref-hint">Read-only fields can still be focused and copied.</p>
</div>
</div>
</section>.ti {
--ti-surface: #ffffff;
--ti-ink: #1d2433;
--ti-muted: #4f5a6e;
--ti-line: #dbe1ec;
--ti-border: #6d788d;
--ti-field: #ffffff;
--ti-disabled: #eef1f6;
--ti-accent: #1d5bd8;
--ti-error: #b3172f;
--ti-error-wash: #fdecef;
--ti-ok: #0c7248;
--ti-ok-wash: #e6f6ee;
--ti-ring: #1d2433;
box-sizing: border-box;
container-type: inline-size;
width: min(100%, 44rem);
padding: 1.5rem;
color: var(--ti-ink);
background: var(--ti-surface);
border: 1px solid var(--ti-line);
border-radius: 18px;
box-shadow: 0 1px 2px rgb(29 36 51 / 6%), 0 14px 32px -14px rgb(29 36 51 / 24%);
font: 1rem/1.45 system-ui, system, "Segoe UI", Roboto, sans-serif;
}
.ti *, .ti *::before, .ti *::after { box-sizing: border-box; }
.ti__title { margin: 0; font-size: 1.35rem; line-height: 1.25; }
.ti__lede { margin: 0.35rem 0 1.25rem; max-width: 34rem; font-size: 0.9rem; color: var(--ti-muted); }
.ti__grid { display: grid; gap: 1.1rem 1.25rem; }
.ti__field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.ti__label { font-size: 0.9rem; font-weight: 700; }
.ti__input {
width: 100%; min-height: 44px; padding: 0.5rem 0.8rem; font: inherit; color: var(--ti-ink); background: var(--ti-field);
border: 1.5px solid var(--ti-border); border-radius: 10px; transition: border-color 0.15s ease, background-color 0.15s ease;
}
.ti__input::placeholder { color: var(--ti-muted); opacity: 1; }
.ti__input:hover:not(:disabled) { border-color: var(--ti-ink); }
.ti__input:focus-visible { outline: 3px solid var(--ti-ring); outline-offset: 2px; border-color: var(--ti-ink); }
.ti__input:disabled { color: var(--ti-muted); background: var(--ti-disabled); border-style: dashed; cursor: not-allowed; }
.ti__input[readonly] { background: var(--ti-disabled); border-color: var(--ti-line); }
.ti__input--area { min-height: 5.5rem; resize: vertical; }
.ti__group { position: relative; display: flex; align-items: stretch; }
.ti__group .ti__input--group { border-radius: 10px 0 0 10px; text-align: right; }
.ti__affix { flex: none; white-space: nowrap; display: grid; place-items: center; min-width: 2.75rem; padding: 0 0.7rem; font-size: 0.85rem; font-weight: 700; color: var(--ti-muted); background: var(--ti-disabled); border: 1.5px solid var(--ti-border); }
.ti__affix:last-child { border-left: 0; border-radius: 0 10px 10px 0; }
.ti__icon { position: absolute; top: 50%; left: 0.8rem; color: var(--ti-muted); transform: translateY(-50%); pointer-events: none; }
.ti__input--search { padding-left: 2.5rem; }
.ti__hint { margin: 0; font-size: 0.8rem; color: var(--ti-muted); }
.ti__msg { display: none; margin: 0; padding: 0.3rem 0.6rem; font-size: 0.85rem; font-weight: 600; border-radius: 8px; }
.ti__msg span { display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; margin-right: 0.2rem; font-size: 0.75rem; font-weight: 800; border-radius: 50%; }
.ti__msg--error { color: var(--ti-error); background: var(--ti-error-wash); }
.ti__msg--error span { color: var(--ti-error-wash); background: var(--ti-error); }
.ti__msg--ok { color: var(--ti-ok); background: var(--ti-ok-wash); }
.ti__msg--ok span { color: var(--ti-ok-wash); background: var(--ti-ok); }
.ti__input:user-invalid { border-color: var(--ti-error); background: var(--ti-error-wash); }
.ti__input:user-invalid ~ .ti__msg--error,
.ti__group:has(.ti__input:user-invalid) ~ .ti__msg--error { display: block; }
.ti__input:user-invalid ~ .ti__hint,
.ti__group:has(.ti__input:user-invalid) ~ .ti__hint { display: none; }
.ti__input:user-valid:not(:placeholder-shown) { border-color: var(--ti-ok); }
.ti__input:user-valid:not(:placeholder-shown) ~ .ti__msg--ok { display: block; }
@container (min-width: 34rem) {
.ti__grid { grid-template-columns: 1fr 1fr; }
.ti__field--wide { grid-column: 1 / -1; }
}
@media (max-width: 26rem) {
.ti { padding: 1rem; }
}
@media (prefers-color-scheme: dark) {
.ti {
--ti-surface: #171d2b; --ti-ink: #eaeef8; --ti-muted: #a9b3c8; --ti-line: #2c3650; --ti-border: #7e8aa5; --ti-field: #1f2638;
--ti-disabled: #232b40; --ti-accent: #7da4ff; --ti-error: #ff9aa9; --ti-error-wash: #3a1d27; --ti-ok: #6fdcaa; --ti-ok-wash: #16352a; --ti-ring: #eaeef8;
box-shadow: 0 1px 2px rgb(0 0 0 / 35%), 0 16px 34px -14px rgb(0 0 0 / 70%);
}
}
@media (prefers-reduced-motion: reduce) {
.ti__input { transition: none; }
}
@media (forced-colors: active) {
.ti__input:focus-visible { outline-color: Highlight; }
.ti__msg { border: 1px solid CanvasText; }
}Written by the author of the snippet. Each note has a test step or a markup check that reads the page.
FormsA contact form with per-field rules, messages tied to each field and an error summary that links to the first problem, using XON.
FormsA three-step form with a step list, back and next buttons, a check on each step before you move on and a review step. Written with XON.
FormsStyled native checkboxes, radio buttons, option cards and chip toggles that keep their keyboard behaviour, group labels and a strong focus ring.