Provide an interface for selecting a date in a form. Implements the WAI-ARIA Date Picker design pattern.
This feature can be used on any page where selecting a date in a form is required.
date type applied to it.<span class="datepicker-format"></span> to hide it when the polyfill doesn't load (due to native support).min attribute containing the earliest date that can be selected by the user.max attribute containing the latest date that can be selected by the user.<div>
<label for="startdate">Start Date<span class="datepicker-format"> (<abbr title="Four digits year, dash, two digits month, dash, two digits day">YYYY-MM-DD</abbr>)</span></label>
<input type="date" id="startdate" name="startdate" min="2013-03-27" max="2013-05-07" />
</div>
<div>
<label for="enddate">End Date<span class="datepicker-format"> (<abbr title="Four digits year, dash, two digits month, dash, two digits day">YYYY-MM-DD</abbr>)</span></label>
<input type="date" id="enddate" name="enddate" min="2013-03-27" max="2016-05-07" />
</div>
| Option | Description | How to configure | Example |
|---|---|---|---|
| Hide Date Format | Hide the date format when the polyfill doesn't load (due to native support) | Wrap the date format in the label with: |
|
| Min Date | The earliest date that can be selected by the user. | Add a "min" attribute to the input field with a YYYY-MM-DD date as the value. |
|
| Max Date | The latest date that can be selected by the user. | Add a "max" attribute to the input field with a YYYY-MM-DD date as the value. |
|
| Event | Trigger | What it does |
|---|---|---|
wb-init.wb-date |
Triggered manually (e.g., $( "input[type=date]" ).trigger( "wb-init.wb-date" );). |
Used to manually initialize the input type="date" polyfill. Note: The input type="date" polyfill will be initialized automatically unless the input type="date" element is added after the page has already loaded. |
wb-ready.wb-date (v4.0.5+) |
Triggered automatically after the input type="date" polyfill initializes. Note: This event will only be triggered if the polyfill is loaded. The polyfill will not load for browsers with native input type="date" support. |
Used to identify where the input type="date" polyfill initialized (target of the event)
|
wb-ready.wb (v4.0.5+) |
Triggered automatically when WET has finished loading and executing. | Used to identify when all WET plugins and polyfills have finished loading and executing.
|
Source code for the input type="date" polyfill (date picker)