0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Length limits for text fields and textareas: maxlength stops typing at the limit, minlength makes a too-short value invalid. Vanilla Breeze adds a live counter and custom messages.
Overview
maxlength sets the most characters a user can enter: the browser stops accepting input at the limit and truncates pastes. minlength sets the fewest: a shorter, non-empty value is invalid (validity.tooShort) and blocks submission. Both count UTF-16 code units, and both are checked against what the user typed, not what a script wrote.
Applies to:<textarea> and <input> of type text, search, url, tel, email and password. Not number, date or other types; use min and max there.
Limits, a counter and custom messages
1234567891011121314151617
<formdata-validate><form-field><labelfor="handle">Display name</label><inputtype="text"id="handle"name="handle"requiredminlength="3"maxlength="24"data-message-tooshort="Use at least 3 characters." /><outputclass="hint"for="handle">3 to 24 characters.</output><outputclass="error"for="handle"aria-live="polite"></output></form-field><form-field><labelfor="bio">Bio</label><textareaid="bio"name="bio"rows="3"maxlength="160"data-count></textarea><outputclass="hint"for="bio">Shown on your public profile.</output></form-field><buttontype="submit">Save profile</button></form>
The user can't enter more. A value over the limit (set by script or the server) is accepted but becomes tooLong once the user edits it.
minlength
Integer ≥ 0, not above maxlength
A user-edited, non-empty value shorter than this is tooShort.
Either
Absent, negative or not an integer
No limit (the default). The DOM properties maxLength and minLength return -1.
An empty field passes minlength. Add required when it must be filled.
Examples
Exact length
Set both to the same number for a fixed-length code, and add pattern if the characters matter.
Six-character invite code
<form-field><labelfor="invite">Invite code</label><inputtype="text"id="invite"name="invite"requiredminlength="6"maxlength="6"pattern="[A-Z0-9]{6}"autocomplete="off"data-message-patternmismatch="Use the 6 letters and digits from your invitation." /><outputclass="hint"for="invite">6 letters and digits, from your invitation email.</output><outputclass="error"for="invite"aria-live="polite"></output></form-field>
Password length
Set a minimum and leave the maximum generous (or absent). A low maxlength on a password silently truncates pasted passphrases from a password manager.
New password
<form-field><labelfor="password">New password</label><inputtype="password"id="password"name="password"autocomplete="new-password"requiredminlength="12"data-message-tooshort="Use at least 12 characters." /><outputclass="hint"for="password">At least 12 characters. A long passphrase beats symbols.</output><outputclass="error"for="password"aria-live="polite"></output></form-field>
Word limits
There is no native word limit. data-count="words" with data-maxwords shows a word count and warns, but does not make the field invalid; keep a maxlength for a hard cap.
data-count on a <textarea> adds a counter below it that reads its limit from maxlength ("40 of 160 characters"). The counter turns to a warning colour at 80% and to bold error colour at the limit, is linked with aria-describedby, and announces the count through a polite live region near the limit (src/utils/textarea-count-init.js). Inside <form-field>, the field keeps the counter in the control's aria-describedby list next to the hint.
Messages.data-message-tooshort and data-message-toolong on the control set the text in output.error (src/web-components/form-field/logic.js).
data-mask sets maxlength to the mask's length when you haven't.
OTP fields.input[data-type="otp"] in a <form-field> sets maxlength to its data-length (default 6).
Components.<chat-input> takes a maxlength (default 4000) and refuses to send a longer message. <markdown-editor> adopts your authored <textarea> with its minlength and maxlength, so the native limits apply.
Accessibility
State the limit in visible text before the user hits it. A field that silently stops accepting characters is confusing, especially for screen-reader users who don't see the text stop growing. The data-count counter and an output.hint both do this.
Make the tooShort message say how many characters are needed.
Don't truncate data the user can't see: a maxlength lower than real names, addresses or passwords causes silent data loss.
Gotchas
Code units, not characters. An emoji such as 👍 counts as 2, and a flag or family emoji as more. Allow headroom on fields where people type emoji.
Only user edits are checked. A value set by script or rendered by the server can be longer or shorter than the limits without being invalid, until the user edits it. Validate on the server.
Before Safari 17, a line break in a textarea counted as two characters toward maxlength.
The browser enforces maxlength while typing even with novalidate; that attribute only affects submit-time checks.
minlength greater than maxlength is an authoring error; the field can never be valid.