<!DOCTYPE html>
<html>
<head>
    <title>生成 6 位随机数二维码</title>
    <meta charset="utf-8">
    <script src="https://cdn.staticfile.org/qrcodejs/1.0.0/qrcode.min.js"></script>
</head>
<body>
    <h1>生成 6 位随机数二维码</h1>
    <form>
        <label for="code">请输入6位数:</label>
        <input type="text" id="code" name="code" maxlength="6" required>
        <button type="button" onclick="generate()">生成二维码</button>
    </form>
    <div id="qrcode"></div>
<pre><code>&lt;script&gt;
    function generate() {
        var code = document.getElementById(&quot;code&quot;).value;
        if (code.length == 6) {
            var qrcode = new QRCode(document.getElementById(&quot;qrcode&quot;), {
                text: code,
                width: 256,
                height: 256,
                colorDark : '#000000',
                colorLight : '#ffffff',
                correctLevel : QRCode.CorrectLevel.H
            });
        } else {
            alert('请输入6位数字!');
        }
    }
&lt;/script&gt;
</code></pre>
</body>
</html>
HTML 生成 6 位随机数二维码 - 在线工具

原文地址: https://www.cveoy.top/t/topic/m0ga 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录