0

Just a simple challenge that I'm facing. I'm using Bootstrap Validator to validate my forms and I want to integrate it with Google reCaptcha.

My code

  <div class="form-group">
                  <div class="g-recaptcha" data-sitekey="my site key"></div>
                  <span class="help-block" style="display: none;">Please check that you are not a robot.</span>
                </div>
                <span class="help-block" style="display: none;">Please enter a the security code.</span>
<script src="https://www.google.com/recaptcha/api.js"></script>

How to I make it required so that a user cannot submit it without completing the captcha. I've found some javascript to do it but I want to integrate it with this library.

Update

I've used something like this and it works. You can provide feedback if you wish.

<div class="form-group container-captcha">
   <label  style="display:none;" for="">Check "I am human" below <span class="required"></span></label>
   <input type="text" name="recaptcha" required value="" id="recaptchaValidator" pattern="1" data-error="Check `I am human` !" style="display:none;">
   <div class="g-recaptcha" data-sitekey="my site key" data-callback="captcha_onclick" align="center" ></div>
   <p class="help-block with-errors">Prove you are a human!</p>
   <script>
      function captcha_onclick() {
          $('#recaptchaValidator').val(1);
          $('#my-form-id').validator('validate')
      }
   </script>
</div>

<script src="https://www.google.com/recaptcha/api.js"></script>
Daniel Richter
  • 340
  • 1
  • 5
  • 25
Daniel
  • 311
  • 3
  • 5
  • 16
  • [Here's a SO answer that says he did it with Bootstrap validator](http://stackoverflow.com/a/31331275/3585500). – ourmandave Oct 09 '16 at 18:07

1 Answers1

0

you can refer reCaptcha referance

Shrikant
  • 94
  • 1
  • 4
  • Yeah but he is checking it using php and I would like to be consistent and use the same method for validation on the forms. – Daniel Oct 09 '16 at 17:34