<div id="datepickerExample1"></div> <div id="datepickerExample2"></div>
new hx.DatePicker('#datepickerExample1');
new hx.DatePicker('#datepickerExample2', {type: 'datepicker'});
<div id="dateRangePicker"></div>
new hx.DatePicker('#dateRangePicker', {selectRange: true});
<input id="datePickerInput" />
new hx.DatePicker('#datePickerInput');
<input id="datePickerV2" placeholder="DD/MM/YYYY" />
new hx.DatePicker('#datePickerV2', {
v2Features: {
dontModifyDateOnError: true,
displayLongMonthInCalendar: true,
dontSetInitialInputValue: true,
updateVisibleMonthOnDateChange: true,
},
});
true
new Date()
setHours(0,0,0,0)
applied false
false
false
false
<input />
element as the container for the date picker. dontModifyDateOnError: true
const input = hx.select('input#myInput')
new hx.DatePicker(input, {
dateValidityCallback: (valid) => {
input.node().setCustomValidity(valid ? '' : 'Please enter a valid date')
}
})
const input = hx.select('input#myInput')
new hx.DatePicker(input, {
validRange: {
start: new Date(...),
end: new Date(...),
},
dateValidityCallback: (valid, validityEnum) => {
let message;
switch(type) {
case 'INVALID_DATE':
message = 'Please enter a valid date'
break;
case 'DATE_OUTSIDE_RANGE_START':
case 'DATE_OUTSIDE_RANGE_END':
message = 'Please enter a date inside the valid range'
break;
default:
message = '';
}
input.node().setCustomValidity(message)
}
})
false
when the date entered is invalid or when it is outside the valid range. validEnum
argument can be used to distinguish between types 'INVALID_DATE'
- Caused by the user entering a value that cannot be converted to a date 'DATE_OUTSIDE_RANGE_START'
- Caused when using the validRange
option and the date is earlier than the start of the valid range 'DATE_OUTSIDE_RANGE_END'
- Caused when using the validRange
option and the date is later than the end of the valid range datepicker.locale('pl') // sets the datepicker's locale to Poland
selectRange
argument was passed into the constructor. selectRange
argument was passed into the constructor. datepicker.validRange({start: new Date}); // User can select any date after today
datepicker.validRange({start: undefined, end: new Date()}); // User can select any date before today
datepicker.validRange({start: new Date(), end: new Date()}); // User can only select today
datepicker.validRange({}); // Clear valid range (all dates are valid)
<input>
instead of a <div>
for the node to apply the datepicker to.