Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Code Generator</title>
- <style>
- body {
- font-family: sans-serif;
- text-align: center;
- }
- #generatedCode {
- font-size: 2em;
- font-weight: bold;
- margin-top: 20px;
- }
- </style>
- </head>
- <body>
- <h1>Your Secret Code</h1>
- <div id="generatedCode"></div>
- <button onclick="generateCode()">Generate New Code</button>
- <script>
- function generateCode() {
- const length = 8;
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
- let code = '';
- for (let i = 0; i < length; i++) {
- code += characters.charAt(Math.floor(Math.random() * characters.length));
- }
- document.getElementById('generatedCode').innerText = code;
- // You might want to store this code somewhere if you need server-side verification
- console.log("Generated Code:", code);
- }
- // Generate an initial code when the page loads
- generateCode();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement