Ask a user for a birthday
const [birthdate, setBirthdate] = useState<Date | undefined>(undefined);<GoabxFormItem label="What is your date of birth?">
<GoabxDatePicker
name="birthdate"
type="input"
value={birthdate}
onChange={(e) => setBirthdate(e.value)}
/>
</GoabxFormItem>birthdate: Date | undefined;
onDateChange(event: { value: Date }) {
this.birthdate = event.value;
}<goabx-form-item label="What is your date of birth?">
<goabx-date-picker
name="birthdate"
type="input"
[value]="birthdate"
(onChange)="onDateChange($event)">
</goabx-date-picker>
</goabx-form-item>const datePicker = document.getElementById("birthdate");
datePicker.addEventListener("_change", (e) => {
console.log("Selected date:", e.detail.value);
});<goa-form-item version="2" label="What is your date of birth?">
<goa-date-picker version="2" name="birthdate" type="input" id="birthdate"></goa-date-picker>
</goa-form-item>Asks for a user’s birthday using the date picker component.
When to use
Use this pattern when you need to collect a date of birth for:
- Age verification
- Identity confirmation
- Benefits eligibility
Considerations
- Consider whether you really need exact birthday vs just year or age range
- The date picker provides a consistent, accessible date selection experience
- Users can type the date directly or use the calendar picker