JS方法 判断 有效日期不能小于今天

 function IsDateCompare(beginDate, endDate) {
            //            var beginArrayDate = /(\d{4})-(\d{1,2})-(\d{1,2})/.exec(beginDate);
            //            var endArrayDate = /(\d{4})-(\d{1,2})-(\d{1,2})/.exec(endDate);
            var beginArrayDate = beginDate.split('-');
            var endArrayDate = endDate.split('-')
            if (parseInt(endArrayDate[0], 10) > parseInt(beginArrayDate[0], 10)) return true;
            if (parseInt(endArrayDate[0], 10) == parseInt(beginArrayDate[0], 10)) {
                if (parseInt(endArrayDate[1], 10) > parseInt(beginArrayDate[1], 10)) return true;
                else {

                    if (parseInt(endArrayDate[1], 10) == parseInt(beginArrayDate[1], 10)) {
                        if (parseInt(endArrayDate[2], 10) >= parseInt(beginArrayDate[2], 10)) return true;
                    }
                }
            }
            return false;
        }
View Code

 

posted @ 2014-12-11 15:13  LuckyZ  阅读(1756)  评论(0编辑  收藏  举报