Date Picker

Edit in →
CodeSandbox

A date picker allows respondents to select a date using a calendar popup or by entering a value manually in an input field. This example demonstrates how to integrate a third-party date picker as a custom SurveyJS question type. Each platform uses a different MIT-licensed date picker component: React Date Picker, Angular Material Datepicker, or Vue Datepicker.

Despite using different libraries, all three implementations share the same question model and behavior, so a single survey JSON definition works across platforms without modification. The integration approach follows the common pattern described in the Form Library tutorials linked at the end of this page.

This demo defines a custom question type that:

  • Renders a third-party date picker inside a SurveyJS form
  • Supports configuration of display format, placeholder, minimum/maximum selectable dates, and clearing behavior
  • Stores the selected value as a normalized yyyy-MM-dd string in survey results (for example, 2026-06-08)

Survey JSON

{
  "elements": [
    {
      "type": "third-party-datepicker",
      "name": "deliveryDate",
      "title": "Preferred delivery date",
      "isRequired": true,
      "dateFormat": "MM/dd/yyyy",
      "placeholder": "Select a date",
      "allowClear": true,
      "minDate": "2026-06-01",
      "maxDate": "2026-12-31"
    }
  ]
}

After completion, the resulting data contains:

{
  "deliveryDate": "2026-06-08"
}

The display format (MM/dd/yyyy06/08/2026) affects only how the value is shown in the UI; it does not affect the stored data format.

Custom Question Properties

The date picker extends the standard Question class with the following properties:

Property Type Default Description
dateFormat string "MM/dd/yyyy" Controls how the date is displayed in the input using date-fns tokens. Not applicable in Angular (see note below).
placeholder string "" Placeholder text shown when no date is selected.
allowClear boolean true Enables clearing the selected date. When disabled, the value can only be changed via the calendar UI.
minDate string "" Minimum selectable date in yyyy-MM-dd format. Empty means no lower bound.
maxDate string "" Maximum selectable date in yyyy-MM-dd format. Empty means no upper bound.

Angular Material does not support per-control format strings. Date display is configured globally via the MAT_DATE_FORMATS injection token. The Angular demo uses a global format matching MM/dd/yyyy (e.g., 06/08/2026) and ignores the dateFormat property. To change formatting, update the DATEPICKER_DATE_FORMATS constant in the Angular implementation.

Integration Tutorials

For step-by-step instructions on integrating third-party components (model definition, serialization, rendering, and registration), see:

Your cookie settings

We use cookies to make your browsing experience more convenient and personal. Some cookies are essential, while others help us analyse traffic. Your personal data and cookies may be used for ad personalization. By clicking “Accept All”, you consent to the use of all cookies as described in our Terms of Use and Privacy Statement. You can manage your preferences in “Cookie settings.”

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.