JS ID number Verification-support for the new ID card with X
function Isidcardno (SID) {
var acity={11: "Beijing", 12: "Tianjin", 13: "Hebei", 14: "Shanxi", 15: "Inner Mongolia", 21: "Liaoning", 22: "Jilin", 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: "Macao", 91: "Foreign"};
var isum=0;
var info= "";
if (!/^d{17} (d|x) $/i.test (SID) &&!/^d{15}$/i.test (SID)) return false;
Sid=sid.replace (/x$/i, "a");
if (Acity[parseint (Sid.substr (0,2))]==null) return false;
Switch (sid.length) {
Case 15:
Sbirthday= "+sid.substr" (6,2) + "-" +number (Sid.substr (8,2)) + "-" +number (Sid.substr (10,2));
var d=new date (Sbirthday.replace (/-/g, "/"));
if (sbirthday!= (d.getfullyear () + "-" + (D.getmonth () +1) + "-" + d.getdate ()) return false;
Break
Case 18:
Sbirthday=sid.substr (6,4) + "-" +number (Sid.substr (10,2)) + "-" +number (Sid.substr (12,2));
var d=new date (Sbirthday.replace (/-/g, "/"));
if (sbirthday!= (d.getfullyear () + "-" + (D.getmonth () +1) + "-" + d.getdate ()) return false;
for (var i = 17;i>=0;i-) Isum + = (Math.pow (2,i)%) * parseint (Sid.charat (17-i), 11);
if (isum%11!=1) return false;
Break
}
return true;
}
Call method
Simple Authentication ID
function C_sfz (v) {
return Isidcardno (v)? True:false;
Return/^ (?:d {15}|d{18}|d{17}[a-za-z]) $/.test (v);
}