jquery日期时间选择器minDate / maxDate问题

时间:2016-03-14 09:31:12

标签: date time picker

下面的代码工作得非常好,但最近我注意到minDate / maxDate不再工作了,很奇怪,因为我没有对代码做任何改动。我已经在这几天苦苦挣扎,这很烦人。

我正在使用此作品 - http://mugifly.github.io/jquery-simple-datetimepicker/

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://mugifly.github.io/jquery-simple-datetimepicker/jquery.simple-dtpicker.js"></script>
<link type="text/css" href="http://mugifly.github.io/jquery-simple-datetimepicker/jquery.simple-dtpicker.css" rel="stylesheet" />


<input type="text" name="start_time" id="start_time">&nbsp;&nbsp;&nbsp;
<input type="text" name="end_time" id="end_time">
<script type="text/javascript">
$(function(){   
    $('#end_time').change(function() {
        $('#start_time').appendDtpicker({
            "futureOnly": true,
            "closeOnSelected": true,
            "dateFormat": "DD/MM/YYYY hh:mm",
            "minTime":"07:00",
            "maxTime":"23:00",
            maxDate: $('#end_time').val() // when the end time changes, update the maxDate on the start field
        });
    });     
    $('#start_time').change(function() {
        $('#end_time').appendDtpicker({
            "futureOnly": true,
            "closeOnSelected": true,
            "dateFormat": "DD/MM/YYYY hh:mm",
            "minTime":"07:00",
            "maxTime":"23:00",
            minDate: $('#start_time').val() // when the start time changes, update the minDate on the end field
        });
    });                     
    // trigger change event so datapickers get attached
    $('#end_time').trigger('change');
    $('#start_time').trigger('change');
});
</script>

0 个答案:

没有答案