JS randomly generated name, cell phone number, ID card number, bank card number "Implementation Code" _JAVASCRIPT skills

Source: Internet
Author: User

Development testing, often need to fill in the name, mobile phone number, ID card number, bank card number, both to meet the format requirements, and can not repeat. People will search the internet for all kinds of generators. Can you write a simple generator of your own? The following is a randomly generated name, mobile phone number, ID card number, bank card number of the JS code.

Generate 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", "especially", "Xu", "Ho", "Lu", "Shi", "Zhang", "Kong", "Cao", "Yan", "Hua", "Jin", "Wei", "Tao", "Ginger", "qi", "Xie", "Zou", "Yu", "Bai", "Shui", "Dou", "Zhang", "Yun", "su", "Pan", "ge  "," Xi, "" Van "," Peng "," Lang "," Lu "," Wei "," Chang "," Horse "," Miao "," Feng "," Hua "," Fang "," Yu "," Ren "," Yuan "," Liu "," Feng ",
        "Bao", "History", "Tang", "fee", "" Lian "," cen "," Xue "," Lei "," he "," ni "," Tang "," Teng "," Yin "," Luo "," bi "," Hao "," WU "," Ann "," Chang ", "Le", "in", "when", "Fu", "" Skin "," Bian "," Qi "," Kang "," WU "," Yu "," Yuan "," bu "," gu "," Meng "," ping "," Huang "," and "," Mu "
    , "Xiao", "Yin"); var givennames = new Array ("Zi Xuan", "Miao", "Guo Dong", "Teacher", "Reidon", "Sweet", "min", "Still", "Guo Yin", "Hexiang", "Morning Tao", "Hao Xuan", "Yi Xuan", "Yi Chen 
    "," Yi Fan "," Yi Ran "," Jin Chun "," Jin Kun "," Chun Qi "," Yang "," Wen Hao "," Dongdong "," Male Lin "," Hao Morning "," Hee-han "," Rongrong "," Ice Maple "," Yan Xin "," Hao "," Hin Hui "," building a government ",    "Mei Xin", "Accomplishment Hui", "he Attributes", "Wen Jie", "Xin Source", "Zhong Lin", "Banyan Run", "Xin ru", "Hui Jia", "new", "Jian Lin", "also Phenanthrene", "Lin", "Ice Jie", "Jia Xin", "Han Han", "Yu Chen", "Chummi", "Ze Hui "," Wai Yang "," Han Yue "," Embellish Li "," Xiang "," Shuhua "," Crystal "," Lingjing "," Yara Creek "," Rain Culvert "," Jia Yi "," Jia Yi "," Zi Chen "," Jia Qi "," Purple Xuan "," Rui Chen "," Xin Rui "," Meng ", "Mingyuan", "Hin Yi", "Ze Far", "Hin Yi", "Jia Yi", "Jia Hui", "Morning XI," Morning Lu "," Yun Hao "," Ru Xin "," Shu Jun "," Crystal 滢 "," embellish "," Ficus "," Jia Yu "," Jia Jade "," Xiao Qing "," a
    
    Ming "," "Language Morning", "Tim Chi", "Tim Hao", "Rain Ze", "Ya 晗", "Ya Han", "" Qing Yan "," Poem Yue "," Jia le "," Chen Han "," Tian-ji "," Yue Ao "," Jia Hao "," Days Hao "," Meng Meng "," if Meng ");
    var i = parseint (Math.random ()) *10 + parseint (Math.random ());
    
    var familyname = familynames[i];
    var j = parseint (Math.random ()) *10 + parseint (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 random phone number function getmoble () {var prefixarray = new Array ("130", "131", "132"
    , "133", "135", "137", "138", "170", "187", "189");
    var i = parseint (A * 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 random ID number function getid_no () {var coefficientarray = ["7", "9", "10", "5", "8", "4", "" 2 "," 1 "," 6 "," 3 "," 7 "," 9 "," 10 "," 5 "," 8 "," 4 "," 2 "];//weighted 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.rand
    Om () *10). ToString ();  
    var array = (address + birthday + s). Split ("");
    var total = 0;
    For (i-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 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 "the": 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 "3Ten ": prefix =" 621717 ";
       Break
       Case "315": prefix = "622323";
       Break
       Case "316": prefix = "622309";       
       Break
    Default: for (var j = 0; J < + 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; }
  }

Above this JS randomly generated name, mobile phone number, ID card number, bank card number "Implementation Code" is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.

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.