Bootstrap-Datetimepicker Not working

后端 未结 4 2102
我在风中等你
我在风中等你 2021-01-02 06:26

I have been looking at this for 2 days, and cant figure out what I am doing wrong.

Here is a fiddle with my project. http://jsfiddle.net/dagger2002/RR4hw/

He

4条回答
  •  甜味超标
    2021-01-02 07:21

    There seemed to be some issues with the external resources in your jsFiddle.

    I have updated jsFiddle to work. I changed the external resources and made some minor adjustments to the code.

    HTML

    Start
    End

    JAVASCRIPT

    jQuery(function () {
        jQuery('#startDate').datetimepicker({ format: 'dd/MM/yyyy hh:mm:ss' });
        jQuery('#endDate').datetimepicker({ format: 'dd/MM/yyyy hh:mm:ss' });
        jQuery("#startDate").on("dp.change",function (e) {
            jQuery('#endDate').data("DateTimePicker").setMinDate(e.date);
        });
        jQuery("#endDate").on("dp.change",function (e) {
            jQuery('#startDate').data("DateTimePicker").setMaxDate(e.date);
        });
    });
    

    UPDATE

    • In your jsFiddle, you reference "bootstrap-datepicker.min.js" and not "bootstrap-datetimepicker.min.js".
    • it seems that "bootstrap-datepicker.min.js" needs "moment.js" as a prerequisite. Please note that the order of includes matter.
    • Finally, "en-gb.js" needs to be listed after "bootstrap-datetimepicker.min.js".

    Updated jsFiddle with working solution.

提交回复
热议问题