In my last article, I discussed how to verify the legality of the 15, 18-bit ID number and get some simple information
For example: Identity, birthdays, gender, etc.
Now, you can take the city and the area.
Copy Code code as follows:
<script language= "JavaScript" >
The area code is really too big, I only posted the code of Beijing, Shanghai, Guangzhou, complete the domestic region code please download the attachment
Go_rush (Asun) from http://ashun.cnblogs.com/
var areacode={
' 11 ': ' Beijing ', ' 1101 ': ' Beijing municipality ', ' 110101 ': ' Dongcheng District ', ' 110102 ': ' Beijing Xicheng District '
, ' 110103 ': ' Chongwen District ', ' 110104 ': ' ' Beijing Xuanwu ', ' 110105 ': ' Chaoyang District, Beijing ', ' 110106 ': ' Fengtai District, Beijing '
, ' 110107 ': ' Shijingshan District of Beijing ', ' 110108 ': ' Beijing Haidian ', ' 110109 ': ' Beijing Mentougou, ' ' 110111 ': ' Beijing Fangshan '
, ' 1102 ': ' Beijing municipality County ', ' 110221 ': ' Beijing Changping ', ' 110222 ': ' Beijing Shunyi ', ' 110223 ': ' Beijing Tongxian '
, ' 110224 ': ' Beijing Daxing County ', ' 110226 ': ' Beijing Pinggu County ', ' 110227 ': ' Beijing Huairou County ', ' 110228 ': ' Miyun County, Beijing '
, ' 110229 ': ' Beijing Yanqing County '
, ' 12 ': ' Tianjin ', ' 1201 ': ' Tianjin Municipal District ', ' 120101 ': ' Tianjin heping District '
, ' 120102 ': ' Tianjin Hedong District ', ' 120103 ': ' Tianjin Hexi District ', ' 120104 ': ' Tianjin Nankai District ', ' 120105 ': ' Tianjin Hebei District '
, ' 120106 ': ' Tianjin Hongqiao District ', ' 120107 ': ' Tianjin Tanggu District ', ' 120108 ': ' Tianjin Hangu District ', ' 120109 ': ' Tianjin Grand Port District '
, ' 120110 ': ' Tianjin Dongli District ', ' 120111 ': ' Tianjin Xiqing District ', ' 120112 ': ' Tianjin Jinnan District ', ' 120113 ': ' Beichen district of Tianjin '
, ' 1202 ': ' Tianjin Municipality County ', ' 120221 ': ' Tianjin Ninghe County ', ' 120222 ': ' Tianjin Wu Qinghen ', ' 120223 ': ' Tianjin Jinghai County '
, ' 120224 ': ' Tianjin Baochi County ', ' 120225 ': ' Tianjin Jixian '
, ' 31 ': ' Shanghai city '
, ' 3101 ': ' Shanghai Municipal District ', ' 310101 ': ' Huangpu District, Shanghai ', ' 310102 ': ' Shanghai Nanshi District ', ' 310103 ': ' Luwan District, Shanghai City '
, ' 310104 ': ' Xuhui District, Shanghai City ', ' 310105 ': ' Shanghai changning ', ' 310106 ': ' Shanghai Jingan ', ' 310107 ': ' Putuo, Shanghai '
, ' 310108 ': ' Shanghai Zhabei ', ' 310109 ': ' Shanghai Hongkou ', ' 310110 ': ' Yang Pu District, Shanghai ', ' 310112 ': ' Shanghai city Minhang '
, ' 310113 ': ' Shanghai Baoshan District ', ' 310114 ': ' Shanghai Jiading ', ' 310115 ': ' Shanghai Pudong New Area ', ' 3102 ': ' Shanghai City Jurisdiction '
, ' 310225 ': ' Shanghai Nanhui County ', ' 310226 ': ' Shanghai Fengxian ', ' 310227 ': ' Shanghai city Songjiang County ', ' 310228 ': ' Shanghai King Mt. County '
, ' 310229 ': ' Shanghai Qingpu County ', ' 310230 ': ' Chongming County, Shanghai City '
, ' 44 ': ' Guangdong province ', ' 4401 ': ' Guangdong province Guangzhou ', ' 440101 ': ' Guangzhou District, Guangdong Province '
, ' 440102 ': ' Guangzhou Dongshan District, Guangdong Province ', ' 440103 ': ' Guangzhou Liwan District, Guangdong Province '
, ' 440104 ': ' Guangzhou Yuexiu District, Guangdong Province ', ' 440105 ': ' Guangzhou Haizhu District, Guangdong Province '
, ' 440106 ': ' Guangdong province Guangzhou Tianhe District ', ' 440107 ': ' Guangdong province Guangzhou Fangcun '
, ' 440111 ': ' Guangzhou Baiyun District, Guangdong Province ', ' 440112 ': ' Guangzhou Huangpu District, Guangdong Province '
, ' 440122 ': ' Guangdong Province from Hua County ', ' 440181 ': ' Guangdong province Fanyu ', ' 440182 ': ' Guangdong province Flower City ', ' 440183 ': ' Guangdong province Zengcheng '
, ' 71 ': ' Taiwan Province ', ' 7100 ': ' Taiwan ', ' 710000 ': ' Taiwan Province '
, ' 72 ': ' Hong Kong ', ' 7200 ': ' Hong Kong Special Administrative Region ', ' 720000 ': ' HKSAR '
, ' 73 ': ' Macau ', ' 7300 ': ' Macao Special Administrative Region '
, ' 91 ': ' Abroad '
}
function Checkid (pId) {
var arrverifycode = [1,0, "X", 9,8,7,6,5,4,3,2];
var Wi = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];
var Checker = [1,9,8,7,6,5,4,3,2,1,1];
if (pid.length!= && pid.length!=) return "The ID number has 15 yards or 18 digits";
var ai=pid.length==18?pid.substring (0,17):p Id.slice (0,6) + "+pid.slice" (6,16);
if (!/^\d+$/.test (Ai)) return "ID card except the last one, must be a number!" ";
var yyyy=ai.slice (6,10), Mm=ai.slice (10,12) -1,dd=ai.slice (12,14);
var d=new date (YYYY,MM,DD), Year=d.getfullyear (), Mon=d.getmonth (), Day=d.getdate (), now=new date ();
if (year!=yyyy | | mon!=mm | | day!=dd | | d>now | | now.getfullyear ()-year>140) return "ID card input Error! ";
for (Var i=0,ret=0;i<17;i++) Ret+=ai.charat (i) *wi[i];
Ai+=arrverifycode[ret%=11];
return pid.length ==18 && pid.tolowercase ()!= Ai? " ID Card input Error! ": Ai;
};
function GetInfo (ID) {
According to the ID card of the province, birthday, gender Go_rush (Asun) from http://ashun.cnblogs.com/
Id=checkid (ID)
if (isNaN (ID)) return "Wrong ID number"
var id=string (id), Sex=id.slice (14,17)%2? " Male ":" Female "
Prov=areacode[id.slice (0,6)] | | Areacode[id.slice (0,4)] | | Areacode[id.slice (0,2)] | | "Unknown Area"
var birthday= (New Date (Id.slice (6,10), Id.slice (10,12) -1,id.slice (12,14))). toLocaleDateString ()
return [Prov,birthday,sex]
}
var id= "110102198006262301"
Alert (GetInfo (ID))
</script>
Download (64KB)
Recommendation: The region code is very large, more than 900 lines, 90Kb size, it is recommended to put them in the database through Ajax to take