Загрузка данных


<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Login + Captcha</title>

<style>
body {
  font-family: Arial;
  background: #f5f5f5;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.container {
  width: 350px;
  background: white;
  padding: 25px;
  border-radius: 15px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

h2 {
  text-align: center;
}

input {
  width: 100%;
  padding: 15px;
  margin: 10px 0;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 16px;
}

button {
  width: 100%;
  padding: 15px;
  background: orange;
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

button:hover {
  background: darkorange;
}

.captcha-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.captcha {
  font-weight: bold;
  font-size: 20px;
  letter-spacing: 3px;
  background: #eee;
  padding: 10px;
  border-radius: 8px;
}

.error {
  color: red;
  font-size: 14px;
}

.success {
  color: green;
  text-align: center;
}
</style>

</head>
<body>

<div class="container">
  <h2>Вход</h2>

  <input type="text" id="login" placeholder="Логин или E-mail">
  <input type="password" id="password" placeholder="Пароль">

  <div class="captcha-box">
    <div class="captcha" id="captcha"></div>
    <button onclick="generateCaptcha()">↻</button>
  </div>

  <input type="text" id="captchaInput" placeholder="Введите капчу">

  <div class="error" id="error"></div>

  <button onclick="login()">Войти</button>

  <div class="success" id="success"></div>
</div>

<script>
let currentCaptcha = "";

// генерация капчи
function generateCaptcha() {
  const chars = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
  currentCaptcha = "";
  
  for (let i = 0; i < 5; i++) {
    currentCaptcha += chars[Math.floor(Math.random() * chars.length)];
  }

  document.getElementById("captcha").innerText = currentCaptcha;
}

generateCaptcha();

// вход
function login() {
  let userCaptcha = document.getElementById("captchaInput").value;
  let error = document.getElementById("error");
  let success = document.getElementById("success");

  error.innerText = "";
  success.innerText = "";

  if (userCaptcha !== currentCaptcha) {
    error.innerText = "Неверная капча!";
    generateCaptcha();
    return;
  }

  success.innerText = "✔ Успешный вход!";
}
</script>

</body>
</html>