Commit 67da77a46924318944171884336d1deacc06a32d

Authored by Hayk Nazaryan
1 parent 151bd32ebb
Exists in master

form feedback captcha

Showing 1 changed file with 23 additions and 2 deletions Side-by-side Diff

resources/views/pages.blade.php
... ... @@ -74,8 +74,8 @@
74 74 <div>
75 75 <h3>Форма обратной связи</h3>
76 76 <p>Все поля обязательны для заполнения.</p>
77   - <form class="callback main__cond-callback" method="POST" action="{{ route('form_feedback') }}">
78   - @csrf
  77 + <form id="submit-form-feedback" class="callback main__cond-callback" method="POST" onsubmit="return validateCaptcha()" action="{{ route('form_feedback') }}">
  78 + @csrf
79 79 <div class="callback__body">
80 80 <input type="text" class="input" name="name" id="name" placeholder="Ваше имя" value="{{ old('name') ?? '' }}" required="">
81 81 @error('name')
... ... @@ -104,6 +104,12 @@
104 104 </div>
105 105 <textarea class="textarea callback__textarea" name="text" id="text" placeholder="Текст сообщения" required="">{{ old('text') ?? '' }}</textarea>
106 106 <div class="callback__bottom">
  107 +
  108 + <div id="Reloadcapcha1" style="width:190px" name="Reloadcapcha1" class="button">Обновить капчу</div>
  109 + <div id="captcha1" style="width:190px" class="modal__reg-item form-group">321</div>
  110 + <input type="text" placeholder="Captcha" class="input registr-form__input" id="cpatchaTextBox1" style="width: 50%"/>
  111 + <span id="captcha_error" class="error-message"></span>
  112 +
107 113 <label class="checkbox">
108 114 <input type="checkbox" name="politik" id="politik" class="checkbox__input" required="">
109 115 <span class="checkbox__icon">
... ... @@ -133,3 +139,18 @@
133 139 @endif
134 140 </div>
135 141 @endsection
  142 +<script>
  143 + document.addEventListener('DOMContentLoaded', function () {
  144 + const form = document.getElementById('submit-form-feedback');
  145 + form.addEventListener('submit', function (event) {
  146 + event.preventDefault();
  147 + if (document.getElementById("cpatchaTextBox1").value == code) {
  148 + console.log('Валидная капча');
  149 + form.submit();
  150 + } else {
  151 + $('#captcha_error').text('Капча неверная!');
  152 + return false;
  153 + }
  154 + });
  155 + });
  156 +</script>