No CAPTCHA reCAPTCHA Resizing

By using the CSS transform property you can achieve changing the width by changing the entire scale of the reCAPTCHA. By adding in just two inline styles, you can make the reCAPTCHA fit nicely on your mobile device: <div class=”g-recaptcha” data-theme=”light” data-sitekey=”XXXXXXXXXXXXX” style=”transform:scale(0.77);-webkit-transform:scale(0.77);transform-origin:0 0;-webkit-transform-origin:0 0;”> </div> More details can be found on my site: https://www.geekgoddess.com/how-to-resize-the-google-nocaptcha-recaptcha/

How to run reCaptcha ONLY if HTML5 validation has passed?

Instead of attaching the reCAPTCHA attributes to the button directly you have to add them to a div and then use grecaptcha.execute(); on form submit. <script src=”https://www.google.com/recaptcha/api.js” async defer></script> <form id=”myForm”> Name: (required) <input id=”field” name=”field” required> <div id=’recaptcha’ class=”g-recaptcha” data-sitekey=”your_site_key” data-callback=”onCompleted” data-size=”invisible”></div> <button id=’submit’>submit</button> </form> <script> $(‘#myForm’).submit(function(event) { console.log(‘validation completed.’); event.preventDefault(); //prevent form submit … Read more

Recaptcha creates iFrame on page, breaks styling

Try the CSS below: /* ReCaptcha Iframe FIX */ iframe {display:none !important;} header iframe, section iframe, footer iframe, div iframe { display:inline; } If you don’t have any other frames on the site to worry about, a simpler version should suffice: iframe {display:none !important;} Alternatively, you could target all iframes where src=”https://stackoverflow.com/questions/8155645/about:blank”: iframe[src=”https://stackoverflow.com/questions/8155645/about:blank”]{display:none;}

How can I process HTML form validation before reCAPTCHA’s validation?

You have to do it programmatically thanks to a new v2 grecaptcha method: grecaptcha.execute() so that recaptcha doesn’t replace the button’s default click event which was preventing the default HTML5 form validation. The event path is: Submit button click event: browser built-in form validation Form submit event: call grecaptcha.execute() reCAPTCHA callback: submit the form $(‘#form-contact’).submit(function … Read more