Advertisement
Barnabas1

reCAPTCHA script

Jun 25th, 2024 (edited)
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- Add reCAPTCHA Script Directly -->
  2. <script src="https://www.google.com/recaptcha/api.js?render=6Ld8KSMpAAAAAL1ITylghSdtPwT2Qy8JB8eIeCG6"></script>
  3.  
  4. <!-- Add reCAPTCHA HTML -->
  5. <input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response">
  6.  
  7. <!-- Add custom script to execute reCAPTCHA -->
  8. <script>
  9.     document.addEventListener('DOMContentLoaded', function() {
  10.         console.log('DOM fully loaded and parsed');
  11.         if (typeof grecaptcha !== 'undefined') {
  12.             <!--console.log('grecaptcha is defined');-->
  13.             grecaptcha.ready(function() {
  14.                 <!--console.log('grecaptcha ready');-->
  15.                 grecaptcha.execute('6Ld8KSMpAAAAAL1ITylghSdtPwT2Qy8JB8eIeCG6', {action: 'checkout'}).then(function(token) {
  16.                     <!--console.log('reCAPTCHA token generated:', token);-->
  17.                     var recaptchaResponse = document.getElementById('g-recaptcha-response');
  18.                     recaptchaResponse.value = token;
  19.                 });
  20.             });
  21.         } else {
  22.             console.log('grecaptcha is not defined');
  23.         }
  24.     });
  25. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement