Date Picker in a Form
Submit ISO dates from a plain HTML form while the field shows a local format. This page documents @pglejzer/datepicker-ui, the companion of timepicker-ui.
Hidden ISO value
#When the input has a name, the picker moves the name to a hidden input placed after it. The form submits the ISO value (YYYY-MM-DD) instead of the displayed text. The hidden input is removed and the name restored on destroy(). Pick a date and submit the form to see what it sends.
Note
The visible input gets
input and change events when a value is committed, and a form reset restores the initial value. In range mode an incomplete range gives an empty string.Two fields for a range
#With ui.endInput, each field with a name gets its own hidden ISO input.
index.html
<input id="start" name="checkin" /><input id="end" name="checkout" /><script type="module">import DatepickerUI from "@pglejzer/datepicker-ui";import "@pglejzer/datepicker-ui/index.css";new DatepickerUI("#start", {calendar: { mode: "range" },ui: { endInput: "#end" },}).create();</script>