Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating jQuery timepicker minTime at runtime dynamically

I am trying to update minTime of jquery time picker dynamically when I put meantime while page loading it works but when I do the same thing when user select start time it should update minTime of end time

here is my attempt to update minTime,

$('#datetimepicker5').timepicker({
timeFormat: 'HH:mm',
    change: tmTotalHrsOnSite
     //  minTime: '15:00'
});
$('#datetimepicker4').timepicker({
timeFormat: 'HH:mm',
    change: tmTotalHrsOnSite
     //  minTime: '15:00'
});


function tmTotalHrsOnSite () {

var picktime = jQuery('#datetimepicker4').val();

    alert(picktime);
jQuery('#datetimepicker5').timepicker({
      minTime: picktime
});
};

I am able to detect time on change and also getting inside the function but not being successful to update minTime to disable users to see the previous time.

like image 619
Kamran Hassan Avatar asked Mar 06 '26 12:03

Kamran Hassan


1 Answers

The thing that worked for me is adding minTime option in onChange event, and passing time value in format specified in timePicker.

    $('.startTP').timepicker({
            timeFormat: 'hh:mm p',
            startTime: '07:00',
            interval: 5,
            dynamic: false,
            dropdown: true,
            scrollbar: true,
            change: function (time) {
                var time = $(this).val();
                var picker = $(".endTP");
                picker.timepicker('option', 'minTime', time);
            }
        });
like image 64
alesija__ Avatar answered Mar 08 '26 02:03

alesija__



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!