Jump to content
  • 0

AJAX или JS ReCaptcha 2.0 без перезагрузки страницы


Kiriklk
 Share

Question

Доброго времени суток! Что-то как ни крути у меня не получается навесить капчу от гугл 2.0. Мне нужно чтобы проверка делалась на JS или AJAX(в крайнем случае), плюс надо все это как то сделать в реальном времени.. Т.е если человек не нажал на квадрат капчи, то ему сразу выскакивало, что ему нужно пройти проверку капчи.. Спасайте)

Вот код HTML.

<!DOCTYPE html><!--[if IE 8 ]><html lang="en" dir="ltr"  class="no-js ie ie8 lt-ie9"><![endif]--><!--[if IE 9 ]><html lang="en" dir="ltr"  class="no-js ie ie9"><![endif]--><!--[if (gt IE 9)|!(IE)]><!--><html lang="en" dir="ltr"  class="no-js"><!--<![endif]--><head>	<meta charset="utf-8" /><script src='https://www.google.com/recaptcha/api.js'></script></head><body id="body" class="html not-front not-logged-in no-sidebars page-contacts with-navigation with-subnav section-contacts" ><div class="panel-separator"></div><div class="panel-pane pane-contact col-2-3 col-last"  >          <h2 class="pane-title">      Обратная связь   </h2>        <div class="pane-content" id="fields">    <form class="user-info-from-cookie contact-form" method="post" action="mail.php" id="contact-site-form" accept-charset="UTF-8"><div><div class="form-item form-type-textfield form-item-name">  <label class="element-invisible" for="edit-name">Ваше имя <span class="form-required" title="This field is required.">*</span></label> <input placeholder="Имя" type="text" id="edit-name" name="name" value="" size="60" maxlength="255" class="form-text required" /></div><div class="form-item form-type-textfield form-item-mail">  <label class="element-invisible" for="edit-mail">Ваш e-mail адрес <span class="form-required" title="This field is required.">*</span></label> <input placeholder="E-mail" type="text" id="edit-mail" name="mail" value="" size="60" maxlength="255" class="form-text required" /></div><div class="form-item form-type-textfield form-item-subject">  <label class="element-invisible" for="edit-subject">Тема <span class="form-required" title="This field is required.">*</span></label> <input placeholder="Тема" type="text" id="edit-subject" name="subject" value="" size="60" maxlength="255" class="form-text required" /></div><div class="form-item form-type-textarea form-item-message">  <label class="element-invisible" for="edit-message">Сообщение <span class="form-required" title="This field is required.">*</span></label> <div class="form-textarea-wrapper resizable"><textarea placeholder="Сообщение" id="edit-message" name="messageText" cols="60" rows="5" class="form-textarea required"></textarea></div></div><input type="hidden" name="form_build_id" value="form-jaFMpYHI7Kl0pc-fEDtCDrlOtx4VxCQQJU7J_9wKq1c" /><input type="hidden" name="form_id" value="contact_site_form" /><div class="g-recaptcha" data-sitekey="6Lc2KBcTAAAAAB-0KS_Us4Hk6fOSwRqNs9gRCYtR"></div><input class="form-button" type="reset" value="Clear"><div class="form-actions form-wrapper" id="edit-actions"><input type="submit" id="edit-submit" name="op" value="Send message" class="form-submit" /></div></div></form></div><div id="note"></div>  </div>  </div></div>  </div></div></div></div>	</div></div>  </div>						</div>											</div>				</div>				<div class="main-after"></div>			</div>						<!-- Region Section bottom 1 -->									<!-- Region Section bottom 2 -->									<!-- Region Section bottom 3 -->									<!-- Region Content bottom -->					</div>		<!-- Footer		======================================================================================= -->		<footer id="footer" class="footer page-footer img-bg parallax-box image-parallax-box" role="contentinfo"><div class="parallax-bg" data-parallax-type="image" data-img-url="Horses/bg02.jpg" data-speed="0.5" data-invert="false"></div> <div id="footer-wrapper" class="footer-wrapper" style="height:1030px;"><div class="container-12"><div class="grid-12"> <div class="region region-footer"><div id="block-block-5" class="block-block-5 block block-block block-copyright grid-6 alpha block-even" style="vertical-align:bottom; position:relative; top:800px;">  <div class="content block-content"><div style="font-size:12px;"><span class="sitename">Лошади</span> © 2016 • <a href="policy.html">Политика конфиденциальности</a></div><div style="margin-top: -5px;"><span class="sitename">Menu Design by Tim Sedov</span></div><div><span class="sitename vk"><a target="_blank" href="https://vk.com/angry_jack_93">Я в ВКонтакте</a></span></div><div style="margin-top: -18px;"><span class="sitename">Maked by Kirill Meier</span></div><div><span class="sitename vk"><a target="_blank" href="http://vk.com/kirillmeier">Я в ВКонтакте</a></span></div><div class="switcher">Desktop Version Only</div> </div></div></div> </div></div></div></footer><script type="text/javascript"><!--//--><![CDATA[//><!--/** * @file *   Main JavaScript file for Dismiss module */(function ($) {  Horse.behaviors.dismiss = {    attach: function (context, settings) {      // Prepend the Dismiss button to each message box.      $('.messages').each(function () {        var flag = $(this).children().hasClass('dismiss');        if (!flag) {          $(this).prepend('<button class="dismiss"><span class="element-invisible">' + Horse.t('Close this message.') + '</span></button>');        }      });      // When the Dismiss button is clicked hide this set of messages.      $('.dismiss').click(function () {        $(this).parent().hide('fast');      });      // Fadeout out status messages when positive value defined.      if (Horse.settings.dismiss.fadeout > 0) {        setTimeout(function () { $('.messages.status').fadeOut(); }, Horse.settings.dismiss.fadeout);      }    }  }})(jQuery);//--><!]]></body></html>

Скриптов пока никаких, так как не увенчалось все успехом.. Я так думаю надо скрипт, что если проверка прошла успешно, то все данные формы отправлять в файл mail.php 

Хотя нет, предоставлю, что нарыл..

<script type="text/javascript">        function fverify() {            $.post( "https://www.google.com/recaptcha/api/siteverify", {secret: "Секретный ключик", response: ""}, function(data) {                alert(data);            });        }    </script>

При таком раскладе выдает ошибку XMLHttpRequest cannot load https://www.google.com/recaptcha/api/siteverify. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://domhorse.ru' is therefore not allowed access.

Edited by Kiriklk
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy