编码规则参考第二代身份证号码编排规则-百度经验 (baidu.com)
function(rule, value, data, callback){ var card = value var wi = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2] var numArr = { 0:1, 1:0, 2:"x", 3:9, 4:8, 5:7, 6:6, 7:5, 8:4, 9:3, 10:2 } var i = 0 var sum = 0 wi.forEach(function(e){ sum += e*(card.substr(i,1)) i = i + 1 }) var last = numArr[sum%11] var comCard = card.substr(0,17)+""+last if(comCard!=card){ callback("身份证验证失败") } return true }
- THE END -
最后修改:2022年7月6日