当前位置:网站首页>The rigorous judgment of ID number is accurate to the last place in the team
The rigorous judgment of ID number is accurate to the last place in the team
2022-06-30 02:43:00 【Under the bridge in front of the gate】
1. The calculation logic of the last digit of the ID number
How to calculate the last digit of the ID card number :
1、 Put the ID number on the front 17 The digits are multiplied by different coefficients .
The coefficients from the first to the seventeenth are :7-9-10-5-8-4-2-1-6-3-7-9-10-5-8-4-2.
2、 Will this 17 The result of multiplication of digits and coefficients is added .
3、 Add and divide by 11, See what the remainder is ?
4、 The remainder can only have 0-1-2-3-4-5-6-7-8-9-10 this 11 A digital .
The number of the last ID card corresponding to them is 1-0-X -9-8-7-6-5-4-3-2.( The remainder 0 Corresponding 1, remainder 1 Corresponding 0, remainder 2 Corresponding X…)
The above content comes from the Internet
Check the specific code
/** * Verification rules of ID card * @param {*} value identity Certificate No * @return {*} Return value promise * adopt then(res) res Accept res It's the object { result:false,msg:" The length or format of your ID card is wrong "} * result:true adopt false Failure */
export function isCardID( value) {
return new Promise((resolve,reject)=>{
if (!/(^\d{15}$)|(^\d{17}(\d|X|x)$)/.test(value)) {
resolve({
result:false,msg:" The length or format of your ID card is wrong "})
}
// ID card City
var aCity = {
11: " Beijing ", 12: " tianjin ", 13: " hebei ", 14: " shanxi ", 15: " Inner Mongolia ", 21: " liaoning ", 22: " Ji Lin ", 23: " heilongjiang ", 31: " Shanghai ", 32: " jiangsu ", 33: " Zhejiang ", 34: " anhui ", 35: " fujian ", 36: " jiangxi ", 37: " Shandong ", 41: " Henan ", 42: " hubei ", 43: " hunan ", 44: " guangdong ", 45: " guangxi ", 46: " hainan ", 50: " Chongqing ", 51: " sichuan ", 52: " guizhou ", 53: " yunnan ", 54: " Tibet ", 61: " shaanxi ", 62: " gansu ", 63: " qinghai ", 64: " ningxia ", 65: " xinjiang ", 71: " Taiwan ", 81: " Hong Kong ", 82: " Macau ", 91: " Abroad " };
if (!aCity[parseInt(value.substr(0, 2))]) {
resolve({
result:false,msg:" Your ID card is illegal "})
}
// Date of birth verification
var sBirthday = (value.substr(6, 4) + "-" + Number(value.substr(10, 2)) + "-" + Number(value.substr(12, 2))).replace(/-/g, "/"),
d = new Date(sBirthday)
if (sBirthday != (d.getFullYear() + "/" + (d.getMonth() + 1) + "/" + d.getDate())) {
resolve({
result:false,msg:" The date of birth on the ID card is illegal "})
}
// ID card number verification
var sum = 0,
weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2],
codes = "10X98765432"
for (var i = 0; i < value.length - 1; i++) {
sum += value[i] * weights[i];
}
var last = codes[sum % 11]; // The last ID card number calculated.
if (value[value.length - 1] != last) {
resolve({
result:false,msg:" The ID number you entered is illegal. "})
}
resolve({
result:true,msg:" Certified as qualified "})
})
}
边栏推荐
- Unity TimeLine 数据绑定
- Global and Chinese markets for light cargo conveyors 2022-2028: Research Report on technology, participants, trends, market size and share
- LeetCode 3. 无重复字符的最长子串
- How do PMP candidates respond to the new exam outline? Look!
- Detailed explanation of minimum stack
- How vscode debugs into standard library files / third-party package source code
- Global and Chinese market of relay lens 2022-2028: Research Report on technology, participants, trends, market size and share
- How to prevent phishing emails? S/mime mail certificate
- [on] [DSTG] dynamic spatiotemporalgraph revolutionary neural networks for traffic data impact
- 新考纲下的PMP考试有多难?全面解析
猜你喜欢

重磅来袭--UE5的开源数字孪生解决方案
![[dry goods sharing] the latest WHQL logo certification application process](/img/c3/37277572c70b0af944e594f0965a6c.png)
[dry goods sharing] the latest WHQL logo certification application process

Call collections Sort() method, compare two person objects (by age ratio first, and by name ratio for the same age), and pass lambda expression as a parameter.

什么是X.509证书?X.509证书工作原理及应用?

CMake教程系列-02-使用cmake代码生成二进制

What is certificate transparency CT? How to query CT logs certificate logs?

Entering Jiangsu writers and poets carmine Jasmine World Book Day

如何在 JupyterLab 中把 ipykernel 切换到不同的 conda 虚拟环境?

Heap sort

Jupyter notebook显示k线图集合
随机推荐
C language pivot_ Invalid argument error resolution for root
Five cheapest wildcard SSL certificate brands
【postgres】postgres 数据库迁移
How difficult is the PMP Exam under the new syllabus? Comprehensive analysis
公司电脑强制休眠的3种解决方案
(图论) 连通分量(模板) + 强连通分量(模板)
Xunwei NXP itop-imx6 development platform
Unity3d ugui force refresh of layout components
CMake教程系列-03-依赖管理
FDA mail security solution
Global and Chinese markets of liquid optical waveguides 2022-2028: Research Report on technology, participants, trends, market size and share
Insert sort directly
Redis+AOP怎么自定义注解实现限流
threejs 镜子案例Reflector 创建镜子+房子搭建+小球移动
原生JS怎么生成九宫格
Jupyter notebook displays a collection of K-line graphs
A quick look at the statistical data of 23 major cyber crimes from 2021 to 2022
隐藏在科技教育中的steam元素
福利抽奖 | 开源企业级监控Zabbix6.0都有哪些亮点
Raii memory management