• 15位身份证转18位


     //15位转18位
        function C15ToC18(c15) {
    
            var cId;
    
            if (c15.length == 15) {
    
                pattern = /^\d{15}$/;
    
                if (pattern.exec(c15) == null) {
    
                    //   alert("15位身份证号码必须为数字!")
    
                    return;
    
                }
    
                if (!isdate("19" + c15.substring(6, 8), c15.substring(8, 10), c15.substring(10, 12))) {
    
                    //alert("身份证号码中所含日期不正确")
    
                    return;
    
                }
    
                cId = c15.substring(0, 6) + "19" + c15.substring(6, 15);
                console.log(cId)
                var strJiaoYan = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
    
                var intQuan = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
    
                var intTemp = 0;
    
                for (i = 0; i < cId.length; i++)
    
                    intTemp += cId[i]* intQuan[i];
    
                console.log(intTemp)
                intTemp %= 11;
                cId += strJiaoYan[intTemp];
    
                return cId;
    
            }
    
            return;
    
        }
    
        //检查年月日是否是合法日期
        function isdate(intYear, intMonth, intDay) {
    
            if (isNaN(intYear) || isNaN(intMonth) || isNaN(intDay)) return false;
    
            if (intMonth > 12 || intMonth < 1) return false;
    
            if (intDay < 1 || intDay > 31) return false;
    
            if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intDay > 30)) return false;
    
            if (intMonth == 2) {
    
                if (intDay > 29) return false;
    
                if ((((intYear % 100 == 0) && (intYear % 400 != 0)) || (intYear % 4 != 0)) && (intDay > 28)) return false;
    
            }
    
            return true;
        }
  • 相关阅读:
    git更新代码
    git标签
    git分支
    命令连接redis
    sql语句
    rm -rf无法删除文件解决方法
    lombda 使用记录
    centos查看磁盘空间大小
    CentOS7 防火墙Firewall常用命令
    安装rabbitmq
  • 原文地址:https://www.cnblogs.com/Leeblog200814/p/15523492.html
Copyright © 2020-2023  润新知