Home Web Front-end JS Tutorial JS code randomly generates name, mobile phone number, ID number, bank card number_javascript skills

JS code randomly generates name, mobile phone number, ID number, bank card number_javascript skills

May 16, 2016 pm 03:03 PM

When developing and testing, you often need to fill in your name, mobile phone number, ID number, and bank card number. They must meet the format requirements and cannot be repeated. Everyone will search for various generators online.

The following is a js generator code written by the editor myself. Randomly generate js code for name, mobile phone number, ID number, and bank card number.

// Generate random name

function getName(){
var familyNames = new Array(
"赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", 
"褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许",
"何", "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏", 
"陶", "姜", "戚", "谢", "邹", "喻", "柏", "水", "窦", "章",
"云", "苏", "潘", "葛", "奚", "范", "彭", "郎", "鲁", "韦", 
"昌", "马", "苗", "凤", "花", "方", "俞", "任", "袁", "柳",
"酆", "鲍", "史", "唐", "费", "廉", "岑", "薛", "雷", "贺", 
"倪", "汤", "滕", "殷", "罗", "毕", "郝", "邬", "安", "常",
"乐", "于", "时", "傅", "皮", "卞", "齐", "康", "伍", "余", 
"元", "卜", "顾", "孟", "平", "黄", "和", "穆", "萧", "尹"
);
var givenNames = new Array(
"子璇", "淼", "国栋", "夫子", "瑞堂", "甜", "敏", "尚", "国贤", "贺祥", "晨涛", 
"昊轩", "易轩", "益辰", "益帆", "益冉", "瑾春", "瑾昆", "春齐", "杨", "文昊", 
"东东", "雄霖", "浩晨", "熙涵", "溶溶", "冰枫", "欣欣", "宜豪", "欣慧", "建政", 
"美欣", "淑慧", "文轩", "文杰", "欣源", "忠林", "榕润", "欣汝", "慧嘉", "新建", 
"建林", "亦菲", "林", "冰洁", "佳欣", "涵涵", "禹辰", "淳美", "泽惠", "伟洋", 
"涵越", "润丽", "翔", "淑华", "晶莹", "凌晶", "苒溪", "雨涵", "嘉怡", "佳毅", 
"子辰", "佳琪", "紫轩", "瑞辰", "昕蕊", "萌", "明远", "欣宜", "泽远", "欣怡", 
"佳怡", "佳惠", "晨茜", "晨璐", "运昊", "汝鑫", "淑君", "晶滢", "润莎", "榕汕", 
"佳钰", "佳玉", "晓庆", "一鸣", "语晨", "添池", "添昊", "雨泽", "雅晗", "雅涵", 
"清妍", "诗悦", "嘉乐", "晨涵", "天赫", "玥傲", "佳昊", "天昊", "萌萌", "若萌"
);
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;
}
} 
Copy after login

//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;
}
}
Copy after login

// Generate a 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"];// 加权因子
var lastNumberArray = [ "1","0","X","9","8","7","6","5","4","3","2"];// 校验码
var address = "420101"; // 住址
var birthday = "19810101"; // 生日
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;
}
} 
Copy after login

//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;
}
}
Copy after login

The above code is all the content of name, mobile phone number, ID number, and bank card number randomly generated by JS. The code is relatively simple. If you have any questions, please leave me a message. The editor will reply to you in time. I also thank you very much. Support for Script House website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Replace String Characters in JavaScript Replace String Characters in JavaScript Mar 11, 2025 am 12:07 AM

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

How do I create and publish my own JavaScript libraries? How do I create and publish my own JavaScript libraries? Mar 18, 2025 pm 03:12 PM

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

How do I optimize JavaScript code for performance in the browser? How do I optimize JavaScript code for performance in the browser? Mar 18, 2025 pm 03:14 PM

The article discusses strategies for optimizing JavaScript performance in browsers, focusing on reducing execution time and minimizing impact on page load speed.

How do I debug JavaScript code effectively using browser developer tools? How do I debug JavaScript code effectively using browser developer tools? Mar 18, 2025 pm 03:16 PM

The article discusses effective JavaScript debugging using browser developer tools, focusing on setting breakpoints, using the console, and analyzing performance.

jQuery Matrix Effects jQuery Matrix Effects Mar 10, 2025 am 12:52 AM

Bring matrix movie effects to your page! This is a cool jQuery plugin based on the famous movie "The Matrix". The plugin simulates the classic green character effects in the movie, and just select a picture and the plugin will convert it into a matrix-style picture filled with numeric characters. Come and try it, it's very interesting! How it works The plugin loads the image onto the canvas and reads the pixel and color values: data = ctx.getImageData(x, y, settings.grainSize, settings.grainSize).data The plugin cleverly reads the rectangular area of ​​the picture and uses jQuery to calculate the average color of each area. Then, use

10 Ways to Instantly Increase Your jQuery Performance 10 Ways to Instantly Increase Your jQuery Performance Mar 11, 2025 am 12:15 AM

This article outlines ten simple steps to significantly boost your script's performance. These techniques are straightforward and applicable to all skill levels. Stay Updated: Utilize a package manager like NPM with a bundler such as Vite to ensure

How to Build a Simple jQuery Slider How to Build a Simple jQuery Slider Mar 11, 2025 am 12:19 AM

This article will guide you to create a simple picture carousel using the jQuery library. We will use the bxSlider library, which is built on jQuery and provides many configuration options to set up the carousel. Nowadays, picture carousel has become a must-have feature on the website - one picture is better than a thousand words! After deciding to use the picture carousel, the next question is how to create it. First, you need to collect high-quality, high-resolution pictures. Next, you need to create a picture carousel using HTML and some JavaScript code. There are many libraries on the web that can help you create carousels in different ways. We will use the open source bxSlider library. The bxSlider library supports responsive design, so the carousel built with this library can be adapted to any

Enhancing Structural Markup with JavaScript Enhancing Structural Markup with JavaScript Mar 10, 2025 am 12:18 AM

Key Points Enhanced structured tagging with JavaScript can significantly improve the accessibility and maintainability of web page content while reducing file size. JavaScript can be effectively used to dynamically add functionality to HTML elements, such as using the cite attribute to automatically insert reference links into block references. Integrating JavaScript with structured tags allows you to create dynamic user interfaces, such as tab panels that do not require page refresh. It is crucial to ensure that JavaScript enhancements do not hinder the basic functionality of web pages; even if JavaScript is disabled, the page should remain functional. Advanced JavaScript technology can be used (

See all articles