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 );
}
});
作者:阿良
出处:http://www.cnblogs.com/arliang
本文采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议
进行许可,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。