The JS Code randomly generates the name, mobile phone number, ID card number, bank card number, and js bank card number.

Source: Internet
Author: User

The JS Code randomly generates the name, mobile phone number, ID card number, bank card number, and js bank card number.

During development and testing, you often need to enter the name, mobile phone number, ID card number, and bank card number, which must comply with the format requirements and must not be repeated. You will search for various generators on the Internet.

Below is a small series of self-written js generator code. Generate a random js Code for name, mobile phone number, ID card number, and bank card number.

// Generate a random name

function getName () {
var familyNames = new Array (
"Zhao", "Money", "Sun", "Li", "Zhou", "Wu", "Zheng", "Wang", "Feng", "Chen",
"Chu", "wei", "jiang", "shen", "han", "yang", "zhu", "qin", "you", "xu",
"He", "Lu", "Shi", "Zhang", "Kong", "Cao", "Yan", "Hua", "Gold", "Wei",
"Tao", "Ginger", "Qi", "Xie", "Zou", "Yu", "Bai", "Water", "Sinus", "Chapter",
"Cloud", "su", "pan", "ge", "ge", "fan", "peng", "lang", "lu", "wei",
"Chang", "Horse", "Miao", "Feng", "Flower", "Fang", "Yu", "Ren", "Yuan", "Liu",
"fēng", "Bao", "History", "Tang", "Fei", "Lian", "Cen", "Xue", "Ray", "He",
"Ni", "Tang", "Teng", "Yin", "Luo", "Bi", "Hao", "Wu", "An", "Chang",
"Yue", "Yu", "Shi", "FU", "Pi", "Bian", "Qiao", "Kang", "Kang", "Yu",
"Yuan", "Bu", "Gu", "Meng", "Ping", "Huang", "He", "Mu", "Xiao", "Yin"
);
var givenNames = new Array (
"Zixuan", "Miao", "Guodong", "Master", "Suitang", "Sweet", "Min", "Shang", "Guoxian", "He Xiang", "Chen Tao",
"Hao Xuan", "Yixuan", "Yi Chen", "Yi Fan", "Yi Ran", "Jin Chun", "Jin Kun", "Chun Qi", "Yang", "Wen Hao",
"Dongdong", "Xionglin", "Hao Chen", "Xi Han", "Rong Rong", "Bing Feng", "Xin Xin", "Yi Hao", "Xin Hui", "Jian Zheng",
"Meixin", "Shuhui", "Wenxuan", "Wenjie", "Xinyuan", "Zhonglin", "Rongrun", "Xinru", "Huijia", "New",
"Jian Lin", "Yi Fei", "Lin", "Bing Jie", "Jia Xin", "Han Han", "Yu Chen", "Chun Mei", "Ze Hui", "Wei Yang",
"Han Yue", "Run Li", "Xiang", "Shu Hua", "Jing Ying", "Ling Jing", "Ling Xi", "Yu Han", "Jia Yi", "Jia Yi",
"Zichen", "Jiaqi", "Zixuan", "Ruichen", "Xin Rui", "Meng", "Ming Yuan", "Xin Yi", "Ze Yuan", "Xin Yi",
"Jia Yi", "Jia Hui", "Chen Qian", "Chen Lu", "Yun Hao", "Ru Xin", "Ru Jun", "Jing Ye", "Run Sha", "Rong Shan",
"Jia Yu", "Jia Yu", "Xiao Qing", "Yi Ming", "Yu Chen", "Tian Chi", "Tian Hao", "Yuze", "Ya Han", "Ya Han",
"Qing Yan", "Shi Yue", "Jia Le", "Chen Han", "Tian He", "Pride", "Jia Hao", "Tian Hao", "Meng Meng", "Ruo Meng"
);
var i = parseInt (* Math.random ()) * + parseInt (* Math.random ());
var familyName = familyNames [i];
var j = parseInt (* Math.random ()) * + parseInt (* Math.random ());
var givenName = givenNames [i];
var name = familyName + givenName;
var x = document.getElementsByName ("client_name");
for (var i =; i <x.length; i ++) {
var o = x [i];
o.value = name;
}
}

// Generate a 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;
}
}

// Generate a random ID card number

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"]; / / Check 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 a 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 code is all the content of the name, mobile phone number, ID card number, and bank card number randomly generated by JS. The code is relatively simple. If you have any questions, please leave a message. The editor will reply to you in time, we are also very grateful for your support for the help House website!


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.