复制代码 代码如下:
<!--forms[]部分-->
<td>
<div id="td12Div" style="display: none;">起始日期:</div>
</td>
<td>
<div id="sdateDiv">
<date:date styleClass="psm-ui-text" name="startDate" property="startDate" divname="dayScope2"
sourceFormat="yyyy-MM-dd" targetFormat="yyyy-MM-dd" readonly="true"/>
</div>
</td>
<!--js部分-->
var startDate=document.forms[0].startDate.value;
var endDate=document.forms[0].endDate.value;
if(DateDiff(endDate,startDate)>3){
alert("日范围不要超过三天");
return;
}
function DateDiff(endDate,startDate)
{
var arrDate,objDate1,objDate2,intDays;
arrDate=endDate.split("-");
objDate1=new Date(arrDate[1]+'-'+arrDate[2]+'-'+arrDate[0]);
arrDate=startDate.split("-");
objDate2=new Date(arrDate[1] + '-'+arrDate[2]+'-'+arrDate[0]);
intDays=parseInt(Math.abs(objDate1-objDate2)/1000/60/60/24);
return intDays;
}