rezzy01

Untitled

Oct 31st, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.54 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="ru">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Контактная форма</title>
  7. <style>
  8. body {
  9. font-family: 'Poppins', sans-serif;
  10. background: linear-gradient(135deg, #6b5b95, #f7bb97);
  11. display: flex;
  12. justify-content: center;
  13. align-items: center;
  14. height: 100vh;
  15. margin: 0;
  16. }
  17. .container {
  18. background: white;
  19. border-radius: 12px;
  20. padding: 30px;
  21. box-shadow: 0 4px 40px rgba(0, 0, 0, 0.2);
  22. width: 90%;
  23. max-width: 500px;
  24. position: relative;
  25. animation: fadeIn 0.5s;
  26. }
  27. @keyframes fadeIn {
  28. from { opacity: 0; }
  29. to { opacity: 1; }
  30. }
  31. h1 {
  32. text-align: center;
  33. color: #333;
  34. font-weight: 500;
  35. margin-bottom: 20px;
  36. }
  37. label {
  38. color: #555;
  39. display: block;
  40. margin-bottom: 8px;
  41. }
  42. input[type="text"],
  43. input[type="tel"],
  44. select {
  45. width: 100%;
  46. padding: 12px;
  47. border: 1px solid #ccc;
  48. border-radius: 6px;
  49. margin-bottom: 20px;
  50. font-size: 16px;
  51. box-sizing: border-box;
  52. transition: border 0.3s, box-shadow 0.3s;
  53. }
  54. button {
  55. background: linear-gradient(90deg, #28a745, #8fd14f);
  56. color: white;
  57. border: none;
  58. padding: 12px;
  59. border-radius: 6px;
  60. cursor: pointer;
  61. width: 100%;
  62. font-weight: bold;
  63. transition: background 0.3s, transform 0.3s;
  64. margin: 15px 0;
  65. }
  66. button:disabled {
  67. background: #ccc;
  68. cursor: not-allowed;
  69. }
  70. .form-part {
  71. display: none;
  72. }
  73. .form-part.active {
  74. display: block;
  75. }
  76. .progress {
  77. display: flex;
  78. height: 8px;
  79. background: #ccc;
  80. border-radius: 4px;
  81. overflow: hidden;
  82. margin-bottom: 20px;
  83. }
  84. .progress-bar {
  85. height: 100%;
  86. background: #28a745;
  87. width: 50%;
  88. transition: width 0.5s ease;
  89. }
  90. .modal {
  91. display: none;
  92. position: fixed;
  93. top: 0;
  94. left: 0;
  95. width: 100%;
  96. height: 100%;
  97. background: rgba(0, 0, 0, 0.5);
  98. justify-content: center;
  99. align-items: center;
  100. }
  101. .modal-content {
  102. background: white;
  103. padding: 20px;
  104. border-radius: 10px;
  105. text-align: center;
  106. animation: fadeIn 0.5s ease-in-out;
  107. }
  108. .rights {
  109. text-align: center;
  110. color: #999;
  111. font-size: 12px;
  112. margin-top: 10px;
  113. }
  114. </style>
  115. </head>
  116. <body>
  117.  
  118. <div class="container">
  119. <h1>Контактная форма</h1>
  120.  
  121. <div class="progress">
  122. <div class="progress-bar" id="progressBar"></div>
  123. </div>
  124.  
  125. <div class="form-part active" id="part1">
  126. <!-- Первая часть формы -->
  127. <label for="name">Имя:</label>
  128. <input type="text" id="name" required placeholder="Ваше имя">
  129.  
  130. <label for="phone">Номер телефона:</label>
  131. <input type="tel" id="phone" required placeholder="+7 (XXX) XXX-XX-XX" onkeypress="return event.charCode >= 48 && event.charCode <= 57">
  132.  
  133. <label for="telegram">Telegram:</label>
  134. <input type="text" id="telegram" required placeholder="@username">
  135.  
  136. <label for="payment">Выберите тип оплаты:</label>
  137. <select id="payment" required>
  138. <option value="" disabled selected>Выберите тип оплаты</option>
  139. <option value="Полная предоплата">Полная предоплата</option>
  140. <option value="Частичная предоплата">Частичная предоплата</option>
  141. <option value="Оплата на месте">Оплата на месте</option>
  142. </select>
  143.  
  144. <button type="button" id="nextButton" onclick="goToPart(2)" disabled>Перейти дальше</button>
  145. </div>
  146.  
  147. <div class="form-part" id="part2">
  148. <!-- Вторая часть формы -->
  149. <label for="from">Откуда отправляемся:</label>
  150. <input type="text" id="from" required placeholder="Город + Адрес" minlength="10">
  151.  
  152. <label for="to">Куда поездка будет:</label>
  153. <input type="text" id="to" required placeholder="Город + Адрес" minlength="10">
  154.  
  155. <label for="bank">Выберите банк:</label>
  156. <select id="bank" required>
  157. <option value="" disabled selected>Выберите банк</option>
  158. <option value="ВТБ">ВТБ</option>
  159. <option value="Сбербанк">Сбербанк</option>
  160. <option value="Т-Банк">Т-Банк</option>
  161. <option value="Альфа-Банк">Альфа-Банк</option>
  162. <option value="Другой">Другой</option>
  163. </select>
  164.  
  165. <label for="time">Время забирания:</label>
  166. <select id="time" required>
  167. <option value="" disabled selected>Выберите время</option>
  168. ${Array.from({length: 19}, (_, i) => `<option value="${i + 5}:00 МСК">${i + 5}:00 МСК</option>`).join('')}
  169. </select>
  170.  
  171. <label>
  172. <input type="checkbox" id="agree" required>
  173. Я соглашаюсь с правилами
  174. </label>
  175.  
  176. <button type="button" id="submitButton" onclick="sendData()" disabled>Отправить</button>
  177. <button type="button" id="backButton" onclick="goToPart(1)">Назад</button>
  178.  
  179. <div class="rights">Все права защищены</div>
  180. </div>
  181. </div>
  182.  
  183. <!-- Модальное окно после отправки -->
  184. <div class="modal" id="successModal">
  185. <div class="modal-content">
  186. <h2>Форма успешно отправлена!</h2>
  187. <button onclick="closeModal()">Понятно</button>
  188. </div>
  189. </div>
  190.  
  191. <script>
  192. let isSubmitting = false;
  193.  
  194. function goToPart(part) {
  195. const parts = document.querySelectorAll('.form-part');
  196. parts.forEach((p, index) => p.classList.toggle('active', index === part - 1));
  197. document.getElementById('progressBar').style.width = part === 2 ? '100%' : '50%';
  198. validateForm();
  199. }
  200.  
  201. function validateForm() {
  202. const requiredFields = ['name', 'phone', 'telegram', 'payment', 'from', 'to', 'bank', 'time'];
  203. let filled = true;
  204.  
  205. requiredFields.forEach(id => {
  206. const input = document.getElementById(id);
  207. if (input && input.parentNode.classList.contains('active') && !input.value) {
  208. filled = false;
  209. }
  210. });
  211.  
  212. document.getElementById('nextButton').disabled = !document.getElementById('name').value || !document.getElementById('phone').value || !document.getElementById('telegram').value || !document.getElementById('payment').value;
  213. document.getElementById('submitButton').disabled = !(document.getElementById('from').value && document.getElementById('to').value && document.getElementById('bank').value && document.getElementById('time').value && document.getElementById('agree').checked && !isSubmitting);
  214. }
  215.  
  216. document.querySelectorAll('input, select').forEach(input => {
  217. input.addEventListener('input', validateForm);
  218. });
  219.  
  220. async function sendData() {
  221. isSubmitting = true;
  222. validateForm();
  223.  
  224. const data = {
  225. name: document.getElementById('name').value,
  226. phone: document.getElementById('phone').value,
  227. telegram: document.getElementById('telegram').value,
  228. payment: document.getElementById('payment').value,
  229. from: document.getElementById('from').value,
  230. to: document.getElementById('to').value,
  231. bank: document.getElementById('bank').value,
  232. time: document.getElementById('time').value,
  233. agree: document.getElementById('agree').checked
  234. };
  235.  
  236. try {
  237. await fetch(`https://api.telegram.org/<YOUR_TOKEN_BOT>/sendMessage`, {
  238. method: 'POST',
  239. headers: { 'Content-Type': 'application/json' },
  240. body: JSON.stringify({
  241. chat_id: '-459027654323',
  242. text: JSON.stringify(data, null, 2)
  243. })
  244. });
  245. showModal();
  246. } catch (error) {
  247. console.error('Ошибка при отправке:', error);
  248. alert('Ошибка при отправке');
  249. } finally {
  250. isSubmitting = false;
  251. validateForm();
  252. }
  253. }
  254.  
  255. function showModal() {
  256. document.getElementById('successModal').style.display = 'flex';
  257. }
  258.  
  259. function closeModal() {
  260. document.getElementById('successModal').style.display = 'none';
  261. location.reload();
  262. }
  263. </script>
  264.  
  265. </body>
  266. </html>
  267.  
Advertisement
Add Comment
Please, Sign In to add comment