可以重新写一个日期控件,将id号传入后台
//引入相关的js和jq.....
开始日期
<input id="startDate" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})" />
结束日期
<input id="endDate" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true})" /><br>
//js代码:
<script type="text/javascript">
$(function(){
setdate();
});
//日期框添加默认值
function setdate(){
var sd=new Date();
sd.setDate(sd.getDate()-1);
var sy=sd.getFullYear();
var sm = sd.getMonth()+1;
var sdd=sd.getDate();
if (sm >= 1 && sm <= 9) {
sm = "0" + sm;
}
if (sdd >= 0 && sdd <= 9) {
sdd = "0" + sdd;
}
var ed=new Date();
ed.setDate(ed.getDate()+1);
var ey=ed.getFullYear();
var em = ed.getMonth()+1;
var edd=ed.getDate();
if (em >= 1 && em <= 9) {
em = "0" + em;
}
if (edd >= 0 && edd <= 9) {
edd = "0" + edd;
}
$("#startDate").val(sy+"-"+sm+"-"+sdd);
$("#endDate").val(ey+"-"+em+"-"+edd);
}
</script>