博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
身份证号码正则匹配-javascript
阅读量:4952 次
发布时间:2019-06-11

本文共 3213 字,大约阅读时间需要 10 分钟。

function a(a, b) {   return a.test(b) } function b(a) {   return a = jQuery.trim(a), 0 == a.length } function c(a) {   return !b(a) }       function t(c) {        if (b(c))            return !1;        c = c.toUpperCase();        var d = {            11 : "北京",            12 : "天津",            13 : "河北",            14 : "山西",            15 : "内蒙古",            21 : "辽宁",            22 : "吉林",            23 : "黑龙江",            31 : "上海",            32 : "江苏",            33 : "浙江",            34 : "安徽",            35 : "福建",            36 : "江西",            37 : "山东",            41 : "河南",            42 : "湖北",            43 : "湖南",            44 : "广东",            45 : "广西",            46 : "海南",            50 : "重庆",            51 : "四川",            52 : "贵州",            53 : "云南",            54 : "西藏",            61 : "陕西",            62 : "甘肃",            63 : "青海",            64 : "宁夏",            65 : "新疆",            71 : "台湾",            81 : "香港",            82 : "澳门",            91 : "国外"        }, e = /(^\d{15}$)|(^\d{17}(\d|X)$)/;        if (a(e, c) === !1)            return !1;        var f = c.substr(0, 2);        if (void 0 == d[f])            return !1;        var g = c.length;        if (15 == g) {            var h = /^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/, i = c.match(h), j = s("19"                    + i[2]), k = s(i[3]), l = s(i[4]), m = new Date("19" + j                    + "/" + k + "/" + l);            m.setFullYear(j), m.setMonth(k - 1), m.setDate(l);            var n = new Date, o = n.getFullYear();            if (m.getFullYear() != j || m.getMonth() + 1 != k                    || m.getDate() != l)                return !1;            var p = o - j;            if (!(p >= 3 && 100 >= p))                return !1        }        if (18 == g) {            var q = /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/, i = c                    .match(q), j = s(i[2]), k = s(i[3]), l = s(i[4]), m = new Date(j                    + "/" + k + "/" + l);            m.setFullYear(j), m.setMonth(k - 1), m.setDate(l);            var n = new Date, o = n.getFullYear();            if (m.getFullYear() != j || m.getMonth() + 1 != k                    || m.getDate() != l)                return !1;            var p = o - j;            if (!(p >= 3 && 100 >= p))                return !1        }        if (15 == c.length) {            var r, t = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8,                    4, 2), u = new Array("1", "0", "X", "9", "8", "7", "6",                    "5", "4", "3", "2"), v = 0;            for (c = c.substr(0, 6) + "19" + c.substr(6, c.length - 6), r = 0; 17 > r; r++)                v += c.substr(r, 1) * t[r];            c += u[v % 11]        }        if (18 == c.length) {            var r, w, t = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5,                    8, 4, 2), u = new Array("1", "0", "X", "9", "8", "7", "6",                    "5", "4", "3", "2"), v = 0;            for (r = 0; 17 > r; r++)                v += parseInt(c.substr(r, 1)) * t[r];            if (w = u[v % 11], w != c.substr(17, 1))                return !1        }        return !0    }

  

转载于:https://www.cnblogs.com/sallet/p/4098977.html

你可能感兴趣的文章
Java 集合工具类---------- Collections类
查看>>
JS-- this
查看>>
用requests库实现登录遇到的问题
查看>>
[Unity动画]03.动画事件
查看>>
关于IIS6.0里跑fastCGI的一个待解问题
查看>>
几种访问Web Service的方式--适用于任何平台任何客户端
查看>>
南阳275
查看>>
k-means原理、优缺点及改进
查看>>
【适配整理】Android 7.0 调取系统相机崩溃解决android.os.FileUriExposedException
查看>>
GitLab版本管理
查看>>
install mongodb on macos
查看>>
A-Z
查看>>
iOS 代码混淆的简单使用
查看>>
购物车升级版本
查看>>
移动端遇到的问题
查看>>
ES6中变量的解析赋值的用途
查看>>
load()和get()的区别
查看>>
可遇不可求的Question之反序列化时出现“base-64 字符数组的无效长度”错误提示篇...
查看>>
[计算机网络]简易http server程序
查看>>
学习MVC之租房网站(二)-框架搭建及准备工作
查看>>