Javascript检查时间不能大于今天
<script language="javascript">
function checkDate(v1)
{
var ar = v1.value;
var ar2='<%=System.DateTime.Now.ToString("yyyy-MM-dd")%>';
var n1 = ar.replace(/-/g, "/");
var n2 = ar2.replace(/-/g, "/");
var date1 = Date.parse(n1);
var date2 = Date.parse(n2);
var d = Math.ceil((date2-date1)/(24*60*60*1000));
if(d<0)
{
alert("时间不能大于今天!");
v1.value="";
return false;
}
}
</script>
function checkDate(v1)
{
var ar = v1.value;
var ar2='<%=System.DateTime.Now.ToString("yyyy-MM-dd")%>';
var n1 = ar.replace(/-/g, "/");
var n2 = ar2.replace(/-/g, "/");
var date1 = Date.parse(n1);
var date2 = Date.parse(n2);
var d = Math.ceil((date2-date1)/(24*60*60*1000));
if(d<0)
{
alert("时间不能大于今天!");
v1.value="";
return false;
}
}
</script>