Ошибка recaptcha при отправке ошибка "Please select the checkbox in the ReCaptcha image"

Добрый день,

Использую Modx 2.8.5, Fetchit, ReCaptchaV2 и Fenom

В форме нормально рендерится гугл кнопка, и по нажатию на которую все работает штатно — появляется зеленая галочка, но при отправке формы возникает ошибка и в логе пишет: «Please select the checkbox in the ReCaptcha image».

Вот код сниппета:

{'!FetchIt' | snippet : [
                    	'snippet' => 'FormIt',
                    	'form' => 'contactForm.tpl',
                    	'hooks' => 'recaptchav2,email',
                    	'emailSubject' => 'Request from website',
                    	'emailTo' => $_modx->config.email,
                    	'emailFrom' => $_modx->config.email,
                    	'emailTpl' => 'email.tpl',
                    	'validate' => 'firstName:required,email:required,g-recaptcha-response:required',
                    ]}

Вот код формы:

<form action="url" method="post" enctype="multipart/form-data" id="form1" class="c-area-availability_form || c-form">
    <div class="c-form_group">
        
        <div class="c-form_item -floating -half f-fname inp">
            <input class="c-form_input" id="input-firstname" type="text" value="" name="firstName"
                placeholder=" " required />
            <label class="c-form_label" for="input-firstname">Your Name</label>
        </div>

            <div class="c-form_item -floating  -half f-email inp">
            <input class="c-form_input" id="input-mail" type="email" name="email" value="" placeholder=" " />
            <label class="c-form_label" for="input-mail">Email Address</label>
        </div>

        <div class="c-form_item -floating f-message">
            <textarea class="c-form_textarea" id="input-mes" name="message" placeholder=" "
                required></textarea>
            <label class="c-form_label" for="input-mes">Describe your need </label>
        </div>
 
    </div>
    <div class="form-item">
      <div id="recaptcha1"></div>
      <span class="error_g-recaptcha-response error"></span>
    </div>
    <div class="c-form_item -floating sentbtn">
        <button class="c-button -color-black c-form_submit" type="submit">
           Submit
        </button>
    </div>
</form>

Также вот скрипт инициализации рекапчи вручную:

<script type="text/javascript">
          var recaptcha1;
          var CaptchaCallback = function() {
            //Render the recaptcha1 on the element with ID "recaptcha1"
            recaptcha1 = grecaptcha.render("recaptcha1", {
              "sitekey" : "6LfUBW8pAAAAAE7ViEjo3woRmUo-0xxxxxxxxxxx", 
              "theme" : "light"
            });
           };
    </script>
    <script src="https://www.google.com/recaptcha/api.js?onload=CaptchaCallback&render=explicit" async defer></script>
То есть я вижу что создается поле g-recaptcha-response и в него приходит значение но после проверки хуком сообщение не отправляется а показывает ошибку Please select the checkbox in the ReCaptcha image.
Сталкивался ли кто-то с такой проблемой?
Konstantin
10 мая 2024, 13:51
modx.pro
147
0

Комментарии: 0

Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
0