Merhaba kendini bu şekilde geliştirmen güzel lakin kodu birazcık daha improve edip oluşan parolaya tıklayınca panoya yapıştırmayıda ekledim extradan.
Umarım yardımcı olur.
İyi forumlar
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; font-family: 'Quicksand', sans-serif; font-weight: 500;}
#password-form {display: flex; flex-direction: column; align-items: center;}
input[type="number"], button, input[type="text"] {font-size: 16px; padding: 10px; border: 1px solid #e7e7e7; border-radius: 4px; margin: 10px 0;}
input[type="number"] {width: 90px; background-color: #ededed;}
button {background-color: #22a7f0; color: white; cursor: pointer;}
button:hover {background-color: #3498db;}
</style>
<title>Password Generator</title>
</head>
<body>
<form id="password-form">
<label for="length">Şifre Uzunluğu:</label>
<input type="number" min="8" max="128" id="length" value="12">
<button type="button" onclick="generatePassword()">Şifre Oluştur</button><br>
<label for="password">Şifreniz:</label>
<input type="text" readonly id="password" style="width: 250px;">
</form>
<script>
document.addEventListener('DOMContentLoaded', () => {
const passwordInput = document.querySelector('#password');
const generatePassword = () => {
const length = document.querySelector('#length').value;
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+-=';
const newPassword = Array.from({ length }, () => characters.charAt(Math.floor(Math.random() * characters.length))).join('');
passwordInput.value = newPassword;
}
const copyToClipboard = () => {
passwordInput.select();
document.execCommand('copy');
window.getSelection().removeAllRanges();
alert('Parola kopyalandı!');
}
document.querySelector('button').addEventListener('click', generatePassword);
passwordInput.addEventListener('click', copyToClipboard);
});
</script>
</body>
</html>