Kod: Markera allt
<html lang="sv-en">
<head dir="rtl.">
<meta charset=UTF-8">
<meta name="viewport" content=width=device-width, initial-scale=1.0">
<title>ALASCAE.com</title>
<link rel="stylesheet" href="_styles.css">
</head>
<body>
<div class="login-container">
<h1>Logga In</h1>
<label for="username">--Användarnamn--</label>
<input type='
' id="username[1]" name="username" required>
<label for="password">--Lösenord--</label>
<input type='
' id="password[3]" name="password" required>
</div>
<button type="submit(name, id)" onclick="const captcha = document.querySelector('.captcha'),
reloadbtn = document.querySelector('.reload'),
inputText = document.querySelector('.input-text input'),
verifyBtn = document.querySelector('.verify'),
responseTxt = document.querySelector('.result');
let characters = [
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
];
function getCaptcha() {
for (let i = 0; i < 6; i++) {
let randomCharacter =
characters[Math.floor(Math.random() * characters.length)];
console.log(randomCharacter);
captcha.innerText += ` ${randomCharacter}`;
//passing 6 random characters
}
}
getCaptcha();
reloadbtn.addEventListener('click', () => {
removeInput();
getCaptcha();
});
verifyBtn.addEventListener('click', (e) => {
e.preventDefault();
responseTxt.style.display = 'block';
let inputVal = inputText.value.split('').join(' ');
if (inputVal == captcha.innerText) {
responseTxt.style.color = '#85C88A';
responseTxt.innerText = "Match!";
setTimeout(() => {
removeInput();
getCaptcha();
}, 2000);
} else {
responseTxt.style.color = '#ff0000';
responseTxt.innerText = 'Captcha not matched. Please try again!';
}
});
function removeInput() {
inputText.value = '';
captcha.innerText = '';
responseTxt.style.display = 'none';
}">Logga In</button>
<div id="error-message st"></div>
</body>
<script src="js/pritected/_login-med.js"></script>
</html>