jQueryUI datePicker 结束时间大于开始时间

$('#js-start-time').datepicker({
    dateFormat:'yy-mm-dd',
    onSelect: function( startDate ) {
        var $startDate = $( "#js-start-time" );
        var $endDate = $('#js-end-time');
        var endDate = $endDate.datepicker( 'getDate' );
        if(endDate < startDate){
            $endDate.datepicker('setDate', startDate - 3600*1000*24);
        }
        $endDate.datepicker( "option", "minDate", startDate );
    }
});
$('#js-end-time').datepicker({
    dateFormat:'yy-mm-dd',
    onSelect: function( endDate ) {
        var $startDate = $( "#js-start-time" );
        var $endDate = $('#js-end-time');
        var startDate = $startDate.datepicker( "getDate" );
        if(endDate < startDate){
            $startDate.datepicker('setDate', startDate + 3600*1000*24);
        }
        $startDate.datepicker( "option", "maxDate", endDate );
    }
});
posted @ 2017-03-29 11:08  FyDong  阅读(605)  评论(0编辑  收藏  举报