The following small series will bring you a javascript randomly generated name, mobile phone number, ID card number, bank card number [Implementation Code ]. I think this is quite good. Now I want to share it with you and give you a reference for development and testing. I often need to enter the name, mobile phone number, ID card number, and bank card number, it must comply with the format requirements and must not be repeated. You will search for various generators on the Internet. Can you write a simple generator by yourself. The following JavaScript code randomly generates the name, mobile phone number, ID card number, and bank card number.
// Generate random name function getName () {var familyNames = new Array ("Zhao", "Qian", "Sun", "Li", "Zhou", "Wu ", "zheng", "Wang", "Feng", "Chen", "Chen", "wei", "Jiang", "shen", "Han", "Yang ", "zhu", "Qin", "you", "Xu", "he", "Lu", "Shi", "Zhang", "Kong", "Cao ", "Yan", "Hua", "Jin", "wei", "Tao", "Ginger", "Qi", "xie", "Yan", "Yu ", "bai", "water", "dou", "Zhang", "Cloud", "Su", "pan", "Ge", "shen", "fan ", "peng", "Lang", "Lu", "wei", "Chang", "Ma", "Miao", "Feng", "Hua", "fang ", "yu", "Ren", "Yuan", "Liu", "Liu", "Bao", "Shi", "Tang", "fee", "Lian ", "CEN", "Xue", "lei", "he", "shen", "Tang", "Teng", "Yin", "Luo", "bi ", "hao", "Jun", "an", "Chang", "Le", "Yu", "Hour", "Fu", "skin", "Lu ", "Qi", "Kang", "Wu", "Yu", "Yuan", "bu", "Gu", "Meng", "ping", "Huang ", "and", "Mu", "Xiao", "Yin"); var givenNames = new Array ("Zi Xuan", "Jun", "Guo Dong", "Fu Zi ", "ruitang", "sweet", "min", "Shang", "Guo Xian", "He Xiang", "Chen Tao", "haoxuan", "Yi Xuan", "Yi Chen ", "Yi fan", "Yi Ran", "Jin Chun", "Jin Kun", "Chun Qi", "Yang", "Wen Hao", "Dong", "Xiong Lin ", "haochen", "Xi Han", "dissolve", "Ice Feng", "xin", "Yi Hao", "Xin Hui", "jian Zheng", "Mei Xin ", "Shu Hui", "Wen Xuan", "Wen Jie", "Xin Yuan", "Zhong Lin", "rong run", "Xin Ru", "Hui Jia", "new ", "Jianlin", "Yifei", "Lin", "Bing Jie", "Jia Xin", "Han", "Yu Chen", "Chunmei", "ze Hui", "Wei Yang ", "Han Yue", "runli", "Xiang", "Shu Hua", "Jing", "Ling Jing", "Xi", "Yu Han", "Jia Yi ", "Jia Yi", "Zi Chen", "Jia Qi", "Zi Xuan", "Rui Chen", "Xin Rui", "Meng", "Ming Yuan", "Xin Yi ", "Ze Yuan", "Xin Yi", "Jia Yi", "Jia Hui", "Chen Qian", "Chen Lu", "Yun Hao", "Ru Xin", "Shu Jun ", "Jingyi", "runsha", "rong Shan", "Jia Yu", "Xiao Qing", "yi ming", "Yu Chen", "Tian Chi ", "Tian Hao", "Yu ze", "", "Han", "Qingyan", "Shi Yue", "Jia Le", "Chen Han", "Tian He ", "Miao AO", "Jia Hao", "Tian Hao", "Meng", "ruomeng"); var I = parseInt (10 * Math. random () * 10 + parseInt (10 * Math. random (); var familyName = familyNames [I]; var j = parseInt (10 * Math. random () * 10 + parseInt (10 * Math. random (); var givenName = givenNames [I]; var name = familyName + givenName; var x = document. getElementsByName ("client_name"); for (var I = 0; I <x. length; I ++) {var o = x [I]; o. value = name ;}}
// Generate the random mobile phone number function getMoble () {var prefixArray = new Array ("130", "131", "132", "133", "135", "137 ", "138", "170", "187", "189"); var I = parseInt (10 * Math. random (); var prefix = prefixArray [I]; for (var j = 0; j <8; j ++) {prefix = prefix + Math. floor (Math. random () * 10);} var x = document. getElementsByName ("mobile_tel"); for (var I = 0; I <x. length; I ++) {var o = x [I]; o. value = prefix ;}}
// Function getId_no () {var coefficientArray = ["7", "9", "10", "5", "8", "4 ", "2", "1", "6", "3", "7", "9", "10", "5", "8", "4 ", "2"]; // weighting factor var lastNumberArray = ["1", "0", "X", "9", "8", "7 ", "6", "5", "4", "3", "2"]; // Verification Code var address = "420101 "; // address var birthday = "19810101"; // birthday var s = Math. floor (Math. random () * 10 ). toString () + Math. floor (Math. random () * 10 ). toString () + Math. floor (Math. random () * 10 ). toString (); var array = (address + birthday + s ). split (""); var total = 0; for (I in array) {total = total + parseInt (array [I]) * parseInt (coefficientArray [I]);} var lastNumber = lastNumberArray [parseInt (total % 11)]; var id_no_String = address + birthday + s + lastNumber; var x = document. getElementsByName ("id_no"); for (var I = 0; I <x. length; I ++) {var o = x [I]; o. value = id_no_String ;}}
// Generate the random bank card number function getBank_account () {var bank_no = document. getElementById ("bank_no_select "). value; var prefix = ""; switch (bank_no) {case "0102": prefix = "622202"; break; case "0103": prefix = "622848"; break; case "0105": prefix = "622700"; break; case "0301": prefix = "622262"; break; case "104": prefix = "621661"; break; case "0303": prefix = "622666"; break; case "305": prefix = "622622"; break; case "0306": prefix = "622556"; break; case "0308": prefix = "622588"; break; case "0410": prefix = "622155"; break; case "302": prefix = "622689"; break; case "304": prefix = "622630"; break; case "309": prefix = "622908"; break; case "310": prefix = "621717"; break; case "315": prefix = "622323"; break; case "316": prefix = "622309"; break; default:} for (var j = 0; j <13; j ++) {prefix = prefix + Math. floor (Math. random () * 10);} var x = document. getElementsByName ("bank_no"); for (var I = 0; I <x. length; I ++) {var o = x [I]; o. value = bank_no;} var y = document. getElementsByName ("bank_account"); for (var I = 0; I <y. length; I ++) {var o = y [I]; o. value = prefix ;}}
The above js randomly generated name, mobile phone number, ID card number, and bank card number [Implementation Code] is all the content shared by Alibaba Cloud. I hope you can give us a reference and support for your feet.