时间插件之结束时间不能小于开始时间
changeDate: function (starttime,stoptime) { //判断时间的大小弹窗提示用户
var _t = this;
if(stoptime != '' && starttime != ''){
if(stoptime < starttime){
$('#stop-date').val('');
$('#time').modal('show');
setTimeout(function(){($('#time').modal('hide'))},3000);
return;
}
}
},
timeDatapicker:function () {
var _t = this; //this
var startDate = $('#start-date'), //开始时间
stopDate = $('#stop-date'); //结束时间
startDate.datetimepicker({
format: 'yyyy-mm-dd',
autoclose: true,
minView: 2,
language:'zh-CN'
}).on('change',function () { //changeData方法写在change之后,是为了防止changeData有changge方法(避免冲突)
var starttime = startDate.val();
var stoptime = stopDate.val();
_t.changeDate(starttime,stoptime);
stopDate.datetimepicker('setStartDate',starttime); //结束时间的选择将以选择的开始时间为依据从新设置(等于开始 时间)
}).on('changeDate',function () {
var starttime = startDate.val();
stopDate.datetimepicker('setStartDate',starttime); //结束时间的选择将以选择的开始时间为依据从新设置(等于开始 时间)
var stoptime = stopDate.val();
});
stopDate.datetimepicker({
format: 'yyyy-mm-dd',
autoclose: true,
minView: 2,
language:'zh-CN'
}).on('change',function () {
var starttime = startDate.val();
var stoptime = stopDate.val();
_t.changeDate(starttime,stoptime,$(this));
}).on('changeDate',function () {
var starttime = startDate.val();
var stoptime = stopDate.val();
startDate.datetimepicker('setEndDate',stoptime);
stopDate.datetimepicker('setStartDate',starttime);
});
},