时间控件(只有年月日)

1 添加控件
<!-- 日期控件 -->
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath
()%>/HRTWEB/css/default.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath
()%>/HRTWEB/css/default.date.css" />
<script type="text/javascript" src="<%=request.getContextPath
()%>/HRTWEB/js/laydate/laydate.js"></script>
2、页面
 <!-- 查询 -->
  开始:<input type="text" id="startTime" class="laydate-icon" />
 结束:<input type="text" id="endTime" class="laydate-icon" />
 <!------------------- 查询 结束 --------------->
3、设置js
/**开始时间*/
 $("#selectRunningProduct").delegate('#startTime', 'click', function() {
  laydate({
   elem: '#startTime',
   format: 'YYYY-MM-DD',
   festival: true, //显示节日
   choose: function(datas){
    var endTime = $("#endTime").val();//结束时间
    if(endTime!=""){
     if(datas>endTime){
      $("#startTime").val("");
      alert("开始时间不能比结束时间还迟,请重新选择开
始时间!");
     }else{
      var queryUrl = contextPath +
"/manage/account/priceChange/proPriceChange/historyQueryByPageForTime.do";
      var startTime = datas;
      proDetailDimPage(queryUrl, startTime, endTime);
     }
    }else{
     var queryUrl = contextPath +
"/manage/account/priceChange/proPriceChange/historyQueryByPageForTime.do";
     var startTime = datas;
     proDetailDimPage(queryUrl, startTime, endTime);
    }
      }
  });
 });
 
 /**结束时间*/
 $("#selectRunningProduct").delegate('#endTime', 'click', function() {
  laydate({
   elem: '#endTime',
   format: 'YYYY-MM-DD',
   festival: true, //显示节日
   choose: function(datas){
    var startTime = $("#startTime").val();
    if(startTime>datas){
     $("#endTime").val("");
     alert("结束时间不能比开始时间还早,请重新选择结束时
间!");
    }else{
     var queryUrl = contextPath +
"/manage/account/priceChange/proPriceChange/historyQueryByPageForTime.do";
     var endTime = datas;
     proDetailDimPage(queryUrl, startTime, endTime);
    }
      }
  });
 });

你可能感兴趣的:(时间控件(只有年月日))