原生js实现身份证号码根据省市区性别日期批量生成器代码

代码语言:html

所属分类:其他

代码描述:原生js实现身份证号码根据省市区性别日期批量生成器代码,采用了身份证号码的生成算法实现,每个号码都是有效的。

代码标签: 原生 j 身份证 号码 根据 省市区 性别 日期 批量 生成器 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>身份信息生成器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
        }
        .container {
            max-width: 800px;
            margin: 0 auto;
        }
        .form-item {
            margin-bottom: 15px;
        }
        .form-label {
            display: inline-block;
            width: 100px;
            margin-right: 10px;
        }
        .form-input-inline {
            display: inline-block;
            margin-right: 10px;
        }
        select, input[type="text"], input[type="number"] {
            padding: 5px;
            border: 1px solid #ddd;
            border-radius: 3px;
        }
        button {
            padding: 10px 20px;
            background-color: #1E9FFF;
            color: white;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }
        button:hover {
            background-color: #1890FF;
        }
        #result {
            margin-top: 20px;
            border-top: 1px solid #ddd;
            padding-top: 20px;
        }
    </style>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/GB2260.js"></script>
</head>

<body>
    <div class="container">
        <form id="idForm" >
            <div class="form-item">
                <label class="form-label">出生地</label>
                <div class="form-input-inline">
                    <select id="province"  name="province"></select>
                </div>
                <div class="form-input-inline">
                    <select id="city" name="city"></select>
                </div>
                <div class="form-input-inline">
                    <select id="district" name="district"></select>
                </div>
            </div>

            <div class="form-item">
                <label class="form-label">出生日期</label>
                <div class="form-input-inline">
                    <input type="radio" name="dateType" value="specific" id="specificDate">
                    <label for="specificDate">指定日期</label>
                    <input type="radio" name="dateType" value="random" id="randomDate" checked>
                    <label for="randomDate">随机</label>
                </div>
            </div>

            <div class="form-item" id="datechoose" style="display:none;">
                <label class="form-label">日期</label>
                <div class="form-input-inline">
                    <input type="date" name="datetime" id="datePicker">
                </div>
            </div>

            <div class="form-item">
                <label class="form-label">性别</label>
                <div class="form-input-inline">
                    <input type="radio" name="gender" value="male" id="male">
                    <label for="male">男</label>
                    <input type="radio" name="gender" value="female" id="female">
                    <label for="female">女</label>
                    <input type="radio" name="gender" value="random" id="randomGender" checked>
                    <label for="randomGender">随机</label>
                </div>
            </div>

            <div class="form-item">
                <label class="form-label">姓名</label>
                <div class="form-input-inline">
                    <input type="radio" name="nameType" value="none" id="noName">
                    <label for="noName">无</label>
                    <input type="radio" name="nameType" value="random" id="randomName" checked>
                    <label for="randomName">随机</label>
                </div>
            </div>

            <div class="form-item">
                <label class="form-label">生成数量</label>
                <div class="form-input-inline">
                    <input type="number" name="quantity" id="quantity" value="10" min="1" max="100">
                </div>
            </div>

            <div class="form-item">
                <div class="form-input-inline">
                    <button type="submit">生成</button>
                </div>
            </div>
        </form>

        <div id="result">
            <!-- 这里放生成的结果 -->
        </div>
    </div>

    <script>
    // 定义姓氏和名字列表
    const surnames = ["王", "李", "张", "刘", "陈", "杨", "赵", "黄", "周", "吴", "徐", "孙", "胡", "朱", "高", "林", "何", "郭", "马", "罗"];
    const givenNames = ["伟", "芳", "娜", "敏", "静", "丽", "强", "磊", "洋", "勇", "军", "杰", "娟", "涛", "明", "霞", "秀英", "华", "平", "刚"];

    // 获取DOM元素
    const provinceSelect = document.getElementById('province');
    const citySelect = document.getElementById('city');
    const districtSelect = document.getElementById('district');
    const datePicker = document.getElementById('datePicker');
    const form = document.getElementById('idForm');
    const resultDiv = document.getElementById('result');

    let data = [];

    // 加载CSV数据
    async function fetchCSVData(url) {
        try {
            const response = await fetch(url);
            if (!response.ok) {
                throw new Error(`HTTP error! status: ${response.status}`);
            }
            const csvText = await response.text();
            return csvText.split('\n').slice(1).filter(row => row.trim() !== '').map(row => {
                const colum.........完整代码请登录后点击上方下载按钮下载查看

网友评论0