<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="datePicker/WdatePicker.js"></script>
<script type="text/javascript">
</script>
</head>
<body>
按日期置无效:
<input id="d1" type="text" class="Wdate" onFocus="WdatePicker({disabledDates:['2015-10-14','2015-10-16']})"/>
<br/><br/>
按日期置有效:
<input id="d2" type="text" class="Wdate" onFocus="WdatePicker({opposite:true,disabledDates:['2015-10-14','2015-10-16']})"/>
</body>
</html>
实际应用:
<input id="input_date" type="text" class="Wdate" style="width:120px;valign:center"/></div>
$(function() { var validate_date_Array=new Array(); //查询所有有效的日期 $.ajax({ type:"POST", url: basePath+"web/queryDateList.action", dataType:"json", async:false, success: function(data){ var dataObj=data.dataObj; //循环得到的List集合,放入数组中 $.each(dataObj,function(index,obj){ validate_date_Array[index]=obj.PUB_TIME; }); //给个默认值 $("#input_date").val(validate_date_Array[0]); } }); //****关键代码****绑定日期控件的onfocus事件,同时将上面得到的有效日期数据绑定到控件中 $("#input_date").on("focus",function(dp){ WdatePicker({ opposite:true,//如果不设置则disabledDates参数中的值会是“无效日期” disabledDates:validate_date_Array,//绑定数组 onpicked:function(dp){ //点击某一日期后触发 //获取当前选中的日期 var curDate=dp.cal.getNewDateStr(); } }); }); });