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>

posted on 2009-07-01 09:03  欧尔  阅读(363)  评论(0编辑  收藏  举报

导航