结束时间小于开始时间不可选择,分钟和今天可以选择显示


html:

        <span class="fl">
		<em>开始时间:</em>
		<input class="laydate-icon" name="begin_time" value="" placeholder="开始时间" id="start" type="text">
	</span>
	<span class="fl">
		<em></em>
		input class="laydate-icon" name="end_time" value="" placeholder="结束时间" id="end" type="text">
	</span>


js:

  var start = {
       elem: '#start', 
       format: 'YYYY/MM/DD', 
    //    min: laydate.now(), //开始时间是否限制今天之前的日期
       istime: false, //是否显示分钟
       istoday: true, //是否显示今天
       choose: function(datas){
        var now = new Date(laydate.now().replace("-", "/")); 
        var add=new Date(datas.replace("-", "/")); 
        add= new Date(add.getTime() + 30*24*60*60*1000); 
        if((now.getMonth() + 1)<(add.getMonth() + 1)){ 
            end.min = laydate.now();  
        }else if ((now.getMonth() + 1)==(add.getMonth() + 1) &&  now.getDate()<add.getDate()) {
            end.min = laydate.now();
        }
        else {
            add=add.getFullYear() + "/" + (add.getMonth() + 1) + "/"+ add.getDate();
            end.min = add;
        }  
        end.min = datas;
      }
    };
    var end = {
      elem: '#end',
      format: 'YYYY/MM/DD',
     min: laydate.now(),
      istime: true,
      istoday: false,
      choose: function(datas){
        var max=new Date(datas.replace("-", "/")); 
        max= new Date(max.getTime() - 30*24*60*60*1000); 
        max=max.getFullYear() + "/" + (max.getMonth() + 1) + "/"+ max.getDate(); 
        start.max = datas; 
        start.min = laydate.now();
      }
    };
    laydate(start);
    laydate(end);



本文转载:CSDN博客