Skip to main content
Topic: client events datetimepicker (Read 1192 times) previous topic - next topic

client events datetimepicker

I have Add form with StartDate and EndDate. I want to set up check that when StartDate is set to e.g. 2020-05-09 then EndDate cannot be set to Date before that StartDate and suggest automatically that EndDate is the same as StartDate.
I want to use the ClientEvents but cannot set the dateTime via this. I can read and alert the values.

Can someone help please?

$('#ctrl-StartDate').on('change', function(){
                //do something like
                //$(this).hide();
                //$(#anotherfieldid).show();
                //var ctrlVal = $(this).val();
alert($('#ctrl-StartDate').val());  <-- this works
alert($('#ctrl-EndDate').val());  <-- this works
alert($(this).val());  <-- this works
                $('#ctrl-EndDate').val($(this).val());<-- this does not work
                $('#ctrl-EndDate').val($('#ctrl-StartDate').val());<-- this does not work
                $('#ctrl-EndDate').datepicker('setDate', new Date(2020,5,9));<-- this does not work
});

Re: client events datetimepicker

Reply #1
@TomRutko‍ this should work
Code: [Select]
$('#ctrl-StartDate').on('change', function(){ 
    flatpickr('#ctrl-EndDate', {
        minDate: Date.parse($(this).val(), 'Y-m-d H:i:S'),
        altFormat: 'F j, Y - H:i',
        dateFormat: 'Y-m-d H:i:S',
        defaultDate: Date.parse($(this).val(), 'Y-m-d H:i:S')
    });
});

Re: client events datetimepicker

Reply #2
Thank you for your help.
defaultDate: Date.parse($(this).val(), 'Y-m-d H:i:S') <-- this works fine is well set up

minDate: Date.parse($(this).val(), 'Y-m-d H:i:S'), <-- is still not set up.

I use the latest - 2.7.3 version