js判断日期格式(YYYYMM)

function datepanduan(obj){
        var date = document.getElementById(obj.id).value;
        var reg = /^\b[1-3]\d{3}(0[1-9]|1[0-2])$/;
        var flg = date.match(reg);
        if( date != null && date != ''){
            if( flg == null ){
                alert('输入错误,请输入“YYYYMM”六位数字格式\n'  );
                obj.focus();
                return false;
            }else{
                alert('输入正确\n');
                return true;
            }
        }
    }

 

posted @ 2016-10-19 13:46  对我有点小自信  阅读(4892)  评论(2编辑  收藏  举报