生成随机身份证和中文名

中文名:

var originalString='赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹姚邵湛汪祁毛禹狄米贝明臧计伏成戴谈宋茅庞熊纪舒屈项祝董梁杜阮蓝闵席季麻强贾路娄危江童颜郭梅盛林刁钟徐邱骆高夏蔡田樊胡凌霍虞万支柯昝管卢莫柯房裘缪干解应宗丁宣贲邓郁单杭洪包诸左石崔吉钮龚程嵇邢滑裴陆荣翁荀羊于惠甄曲家封芮羿储靳汲邴糜松井段富巫乌焦巴弓牧隗山谷车侯宓蓬全郗班仰秋仲伊宫宁仇栾暴甘钭历戎祖武符刘景詹束龙叶幸司韶郜黎蓟溥印宿白怀蒲邰从鄂索咸籍赖卓蔺屠蒙池乔阳郁胥能苍双闻莘党翟谭贡劳逄姬申扶堵冉宰郦雍却璩桑桂濮牛寿通边扈燕冀浦尚农温别庄晏柴瞿阎充慕连茹习宦艾鱼容向古易慎戈廖庾终暨居衡步都耿满弘匡国文寇广禄阙东欧殳沃利蔚越夔隆师巩厍聂晁勾敖融冷訾辛阚那简饶空曾毋沙乜养鞠须丰巢关蒯相查后荆红游竺权逮盍益桓公万俟司马上官欧阳夏侯诸葛闻人东方赫连皇甫尉迟公羊澹台公冶宗政濮阳淳于单于太叔申屠公孙仲孙轩辕令狐徐离宇文长孙慕容司徒司空';
function getStr(){
	var tmp="";
	for(var i=0;i<3;i++)
	{
	var stringLength=Math.random()*originalString.length;
	tmp+=originalString.charAt(Math.ceil(stringLength)%originalString.length);
	}
	return tmp;
}

身份证号:

// /地区编码
	var city = new Array("110113","120223","130403","130425","130433","130731","131000","131023","131024","131081","140106","140222","140226","140227","140524","140600","140828","140922","140981","141129","141130","150426","150525","150727","152525","210201","210300","210801","211101","220103","220182","220203","220323","220500","220821","222400","230108","230307","230703","230710","230833","231003","231222","231223","231281","232721","232722","320201","320302","320503","320584","320724","320831","320902","320982","321003","321081","321181","321201","330000","330108","330122","330183","330205","330225","330411","330600","330723","340103","340207","340301","340603","340802","341221","341421","341521","341822","350206","350427","350526","350721","360421","360425","360428","370105","370611","370685","370687","370883","370900","370921","371311","371422","371424","410302","410782","411081","411421","420607","420800","420900","430102","430122","430225","430301","430401","430511","430624","430922","431027","431127","431201","440306","440703","440923","441400","441821","441827","441882","445321","450100","450224","450521","450701","450923","450981","451022","451029","451421","451424","460200","500232","500237","510106","510112","510183","510503","510601","510683","510903","511524","511602","511823","513224","513229","513328","520300","520326","522422","522633","522700","530103","530501","530702","532600","532622","533324","542100","542125","542227","542322","542331","542421","542424","542525","542626","610301","610429","610528","610702","610901","610926","620524","620901","621124","621201","621226","623026","632126","632523","632821","652300","652901","653000","653022","653121","653123","653128","653200","654021"
	);

	var pow = new Array("7","9","10","5","8","4","2","1","6","3","7","9","10","5","8","4","2");
	var ex = new Array("1","0","X","9","8","7","6","5","4","3","2");

	// /年月日
	function getYMD() {
	    var ymd = "";
	    var y =  parseInt(Math.random() * 99);
	    if(y < 10)y = "0" + y;
	    y = "19" + y;
	    var m =  parseInt(Math.random() * 13);
	    if(m < 10)m = "0" + m;
	    if(m == "00")m = "01";
	    var d =  parseInt(Math.random() * 28);
	    if(d < 10) d = "0" + d;
	    if(d == "00") d = "01";
	    ymd = "" + y + m + d;
	    return ymd;
	}

	//生成号码
	function makeId(){
	    var idcard;
	    idcard = city[parseInt(Math.random() * 189)]
	    + getYMD()
	    + parseInt(Math.random() * 9)       //
	    + parseInt(Math.random() * 9)       //
	    + parseInt(Math.random() * 9);      //

	    var sum = 0;
	    for(var i = 0;i < idcard.length;i++){
	        sum += parseInt(idcard.substring(i,i + 1)) * parseInt(pow[i]);
	    }
	    return  idcard + ex[sum % 11];
	}

 

转发请注明出处http://blog.martoo.cn
如有漏缺,请联系我 QQ 243008827

发表评论

电子邮件地址不会被公开。 必填项已用*标注