I have two DateTimePickers that need to talk together, but I am having problem programatically changing the values of them.
If I try to set the value of a DateTimePicker to "27/11/2019 16:00" the input-field of the picker is cleared and the watermark text is shown.
If I instead use "27-11-2019 16:00" the value is displayed correctly, but this is not the format defined for the control and this is not the format I want to display to the user. The displayed format reverts correctly if I change the date in the control with user input.
I have my DateTimePickers set up with the following rules:
$('#StartDate').ejDateTimePicker({
locale: "da-DK",
dateTimeFormat: "dd/MM/yyyy HH:mm",
width: "auto",
height: 35,
value: $('#StartDate').attr("defaultvalue"),
watermarkText: "Vælg",
buttonText: {
timeNow: "Klokken nu"
},
change: DateTimePickerChanged,
focusIn: DateTimePickerFocused
});
function DateTimePickerFocused(args) {
var dateObj = $('#' + args.model.name).ejDateTimePicker('instance');
dateObj.show();
}
function DateTimePickerChanged(args) {
// the newly selected date may invalidate the other datetimepicker control
// in that case, change the value of the other control
// ... code omitted
$(selector).ejDateTimePicker({ value: '27/11/2019 16:00'}); // setting this value on a datetimepicker fails
}