Search code examples
javascriptjquerykendo-uikendo-datepickermindate

how to change min date of kendo date picker: Jquery


I am creating a web app in which I have 2 date time textbox(txtFromDate, txtToDate), for which I am using Kendo-UI,

On my page load I am setting min date for my txtToDate

Which looks like below

$('#txtToDate').data("kendoDatePicker").min(new Date($('#txtFromDate').val()));

the above code works properly and setting the min date for txtToDate textbox properly,

but the problem is

when user changes from date let say from (05/08/2019) to (05/20/2019)

the min date for txtToDate should be changed from 05/08/2019 to 05/20/2019

but nothing happens, below is my onchange function

$('#txtFromDate').change(function () {
    $('#txtToDate').data("kendoDatePicker").min(new Date($('#txtFromDate').val()));
});

how can I reset the min date for txtToDate Textbox?


Solution

  • I think the problem is that you're binding to the change event of the input, instead of the kendo widget.

    Replace

    $('#txtFromDate').change(function () {
    

    with

    $('#txtFromDate').data("kendoDatePicker").bind("change", function () {
    

    Edited to add: you may also prefer to just use Kendo's date range picker