Date of birth is the field where browser autofill and hand-built HTML most often disagree. A name or email field has one obvious token; a birthday can be one input or three, typed or picked, and browsers read each shape differently. If you have connected your existing form with the Detected Form widget, this guide gives you the Detected form widget Date of birth autocomplete token field-level testing routine: exact tokens per field, labels that survive the change, validation you can still read on submit, and a browser-by-browser autofill matrix so a birthday is never silently overwritten or dropped before launch.
Why birthday fields behave differently from name and email autofill
A name or email is a single value in a single control, so one token such as given-name or email is an unambiguous instruction. A birthday is a compound value — day, month and year — and browsers can either supply the whole date into one input or fill three separate controls if you tell them which part each holds. Mixing the stories (marking a day field bday and leaving the year field tokenless) leaves the browser guessing, and guesses vary between vendors, versions and devices.
Autofill is a convenience layer, not a contract. No specification obliges a browser to offer or apply a stored birthday, and a saved profile value may replace anything you set as a default. That is why the meaningful test happens in real browsers after the widget is installed, not in a code review.
Map each field to a token: bday versus bday-day, bday-month, bday-year
Decide first whether the visitor enters the whole date in one control or in separate controls, then apply exactly one shape.
| Field shape | Token | Expected value |
|---|---|---|
| One text or date input for the full birthday | autocomplete="bday" |
A complete date, typically YYYY-MM-DD |
| Day control in a split group | autocomplete="bday-day" |
Day number only |
| Month control in a split group | autocomplete="bday-month" |
Month number or name, matching your markup |
| Year control in a split group | autocomplete="bday-year" |
Four-digit year |
For a split group, every control is its own autofill target, so each needs its matching token. Do not put bday on a wrapper and expect it to cascade. Wrappers and fieldset/legend are for layout and grouping; the token belongs on the control the browser will fill.
Single input:
<label for="dob">Date of birth (YYYY-MM-DD)</label>
<input id="dob" name="dob" type="date" autocomplete="bday" required>
Split group with text inputs:
<fieldset>
<legend>Date of birth (DD/MM/YYYY)</legend>
<label for="dob-day">Day</label>
<input id="dob-day" name="dob_day" inputmode="numeric" pattern="[0-9]{2}" maxlength="2" autocomplete="bday-day">
<label for="dob-month">Month</label>
<input id="dob-month" name="dob_month" inputmode="numeric" pattern="[0-9]{2}" maxlength="2" autocomplete="bday-month">
<label for="dob-year">Year</label>
<input id="dob-year" name="dob_year" inputmode="numeric" pattern="[0-9]{4}" maxlength="4" autocomplete="bday-year">
</fieldset>
If you use select elements for day and month, the tokens still apply to each select, and each select still needs its own name.
Keep labels and format hints correct after token changes
Changing a token should never cost you a label. Every birthday control needs a real <label for="…"> matched to its id. Add a short format hint near the group or inside the label text, for example “Date of birth (DD/MM/YYYY)”, so visitors do not have to guess whether 03/04 means March or April. Placeholder-only labels vanish as soon as typing starts and leave assistive technology nothing to announce; HTML form labels for clear lead forms covers pairing, wording and hint placement in more depth. If the field is required, mark it visibly and explain the marker as shown in the required field asterisk explainer.
Validation that keeps working with the new tokens
The autocomplete attribute does not change validation rules, so your existing constraints keep applying. Use native attributes first — required, pattern, min/max, minlength/maxlength — and let the browser block invalid submission with its own message. MDN's client-side validation guidance notes that native attributes catch most invalid input without JavaScript, and that invalid controls block submission with a browser message (client-side form validation guidance).
On submit, read element.validity and write your own message into an inline element next to the field, linked with aria-describedby so screen reader users hear it. Remember that client-side checks are a first pass: MDN's form data article explains that named controls still travel as name=value pairs to whatever endpoint handles them, so the value the browser autofills is exactly what the server receives (sending and retrieving form data). For birthdays, keep a server-side re-check that the assembled date is a real calendar date.
Confirm what the Detected Form widget actually captures
A token tells the browser something about a field; a name tells the submission something about it. The widget can only pass along values from named controls. Before testing autofill, confirm:
- Every birthday input and
selecthas a uniquenameattribute. - Split groups use distinct names such as
dob_day,dob_month,dob_year, not three copies ofdob. - No second element shares an
idwith a labelled birthday control. - Hidden or disabled controls that hold prefilled values are not silently excluded from what you expect.
If fields arrive empty after connection, duplicate or missing names are the usual cause; the missing name attribute fix guide walks through the audit order.
Build a repeatable browser-by-browser autofill test
Run this once per release using a browser profile that actually stores a birthday in autofill settings. Use a throwaway test profile, not your personal one. You will also need at least one live submission to inspect in the widget’s submission record.
- Open the page with the widget installed in Chrome, Firefox and Safari on desktop, plus Chrome on Android and Safari on iOS.
- Click into the first birthday control and accept the saved autofill suggestion, or observe the automatic prefill on load.
- Record per control what arrived: correct part, wrong part, overwritten existing value, or nothing.
- Fix the token or
name, clear the field, and repeat. - Submit once with autofilled values and once with typed values, then inspect the submission record field by field.
| Browser | Device | Field tested | Expected | Observed | Pass/Fail |
|---|---|---|---|---|---|
| Chrome | Desktop | dob-day |
Day number | ||
| Chrome | Android | dob-month |
Month number | ||
| Firefox | Desktop | dob-year |
Four-digit year | ||
| Safari | Desktop | bday single input |
YYYY-MM-DD |
||
| Safari | iOS | Split group | All three parts |
A row passes only when the value is correct on screen and survives to the submission record. Autofill that looks right but never reaches your endpoint is a fail.
Common failure modes and fixes
- Prefilled value overwritten. A browser may replace your default with a stored profile value. Decide intentionally which is more helpful, state it in the test expectation, and stop fighting it in code.
- Split group skipped. One control is missing its
bday-day,bday-monthorbday-yeartoken, so the browser has no complete date to offer. Set all three. - Token ignored because the input type does not match. A
numberinput asked to hold a month name, or an input whosetypedoes not match the expected value, invites a silent mismatch. Usetype="date"for a single field, or text withinputmode="numeric"and a pattern for split fields. - Values arriving empty. Check names, duplicate ids, and any script that rewrites the field after autofill. The autofill overwriting values guide covers the detection steps.
- Keyboard path broken. Tab through the group and confirm the order is day, month, year, and that the hint and each label are announced once.
Decide whether you need the full date at all
Before polishing tokens, ask whether you need day, month and year, just a year, or an age band. Collecting less is easier to justify and easier to explain. If you do collect a full date of birth, add a short note near the field saying why, and keep privacy and consent wording consistent with what actually lands in the submission record. The consent checkbox guide shows how consent and sensitive fields are handled without collecting data you do not need.
Pre-launch checklist
- Each birthday control has the correct token:
bday, orbday-day/bday-month/bday-year. - Every control has a real
<label>and a visible format hint. - Native constraints are set, and inline error messages sit beside the field with
aria-describedby. - Keyboard order is day, month, year, and hints are announced once.
- All
nameattributes are unique and present, including everyselect. - The browser matrix has been run with a saved autofill profile on desktop and mobile.
- One real submission has been inspected and each birthday field holds the right value.
Next step
If your form is already live and you want WidgetJar to connect it, review the Detected Form widget page, then run the matrix above on the connected version before you announce anything. A birthday that autofills correctly and still arrives in the record is the only result that counts.