JQuery Datepicker returned Date object type

后端 未结 4 1664
野性不改
野性不改 2021-01-19 13:46

What\'s the object type returned by Datepicker? Supposing I have the following:

$(\"#txtbox\").datepicker({
   onClose: function(date){
          //something         


        
4条回答
  •  盖世英雄少女心
    2021-01-19 14:34

    A Date object is returned by the datePicker.

    Your method for comparing dates is valid - from W3schools:

    var myDate=new Date();
    myDate.setFullYear(2010,0,14);
    var today = new Date();
    
    if (myDate>today)
    {
        alert("Today is before 14th January 2010");
    }
    

    Are you getting a value in oDate from this line?

    oDate = $("#oDP").datepicker("getDate");
    

    Your comparison method seems valid - so I'm wondering if datePicker is successfully pulling a value from #oDP?

    Edit - oDate confirmed to contain a valid date. This may be a very silly question, but have you confirmed that date contains a valid date? I'm wondering if there may be some issue with naming it the same as the keyword Date (Javascript keywords and reserved words). Perhaps try renaming it to tDate or the like in your function to be doubly-clear this isn't causing your problems.

提交回复
热议问题