You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport" content="width=device-width, initial-scale=1.0"><title>Random Password Generator</title><linkrel="stylesheet" href="style.css"><scriptdefersrc="script.js"></script><body><divclass="container">Generate a <br> Random Password</div><divclass="display"><inputtype="text" id="password" placeholder="Password"><inputtype="button" value="copy" id="copy" onclick="copyPassword()"></div><divclass="generatebutton"><inputonclick="generatePassword()" type="button" value="Generate Password" id="GeneratePassword"></div></body></html>
Javascript
constpasswordBox=document.getElementById("password");constlength=16;constupperCase="QWERTYUIOPASDFGHJKLZXCVBNM";constlowerCase="qwertyuiopasdfghjklzxcvbnm"constnumber="1234567890";constsymbol="!@#$%^&*()_+~`|}{[]\:;?><,./-=";constallChar=upperCase+lowerCase+number+symbol;functiongeneratePassword(){letpassword="";// let passwords = password.length;password+=upperCase[Math.floor(Math.random()*upperCase.length)];password+=lowerCase[Math.floor(Math.random()*lowerCase.length)];password+=number[Math.floor(Math.random()*number.length)];password+=symbol[Math.floor(Math.random()*symbol.length)];// get the password until 12 digits while(length>password.length){password+=allChar[Math.floor(Math.random()*allChar.length)];}passwordBox.value=password;}functioncopyPassword(){passwordBox.select();// select the text inside the password box// document.execCommand('Copy'); // copy it to clipboardpasswordBox.execCommand("copy")alert("Copied to clipboard!");}