Javascript code randomly generates name, mobile phone number, ID card number, and bank card number _ javascript skills

Source: Internet
Author: User
The following is a small Editor of the js generator code written by myself. The code is relatively simple and highly practical. If you are interested, let's study it together, 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", "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", "Yu", "bai ", "Water", "sinus", "chapter", "Cloud", "Su", "pan", "Ge", "shen", "fan", "peng ", "Lang", "Lu", "wei", "Chang", "Ma", "Miao", "Feng", "Hua", "fang", "Yu ", "Ren", "Yuan", "Liu", "Liu", "Bao", "Shi", "Tang", "fei", "Lian", "CEN ", "Xue", "lei", "he", "Tang", "Teng", "Yin", "Luo", "bi", "hao ", "Jun", "an", "Chang", "Le", "Yu", "Shi", "Fu", "Pi", "Jun", "Qi ", "Kang", "Wu", "Yu", "Yuan", "bu", "Gu", "Meng", "ping", "yellow", "and ", "Mu", "Xiao", "Yin"); var givenNames = new Array ("Zi Xuan", "Kun", "Guo Dong", "Fu Zi", "ritang ", "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", "haocen ", "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", "jian Lin ", "yi fei", "Lin", "Ice 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", "Jing ", "runsha", "rong Shan", "Jia Yu", "Xiao Qing", "yi ming", "Yu Chen", "Tian Chi", "Tian Hao ", "yuze", "", "Han", "Qingyan", "Shi Yue", "jiale", "Chen Han", "Tian He", "Yu AO ", "Jia Hao", "Tian Hao", "Meng", "ruomeng"); 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"]; // 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 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, at the same time, I would like to thank you for your support for the website!

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.