The date field (type: "date") displays a date field in the modal form() dialog. It allows you to enter a date by either typing it in or using a date picker.
Date Field Properties
- type ("date") - specifies the form field type
- name (string) - the field name that will be displayed above the text box
- id (string) - the path that specifies the source/target property of the data object
- dateFormat (string) - specifies the date format using the syntax used by DayPilot.Date.toString(); optional
- disabled (boolean) - makes the date field disabled (inaccessible and read-only); optional
- cssClass (string) - additional CSS class that will be applied to the form field; optional
- onValidate (function) - a callback function used to validate the field value; optional
Default Values
If dateFormat is not specified, it uses the date format specified by the modal dialog locale.
Example
import {Modal} from "@daypilot/modal";
// ...
async function date() {
const form = [
{
name: "Start",
id: "start",
dateFormat: "d.M.yyyy",
type: "date",
},
];
const data = {
start: "2033-01-02",
};
const modal = await Modal.form(form, data);
console.log(modal.result);
}