title: Google Invisible ReCaptcha on multiple forms in a same page - PHP
body: <p>I am following this Invisible ReCaptcha doc on my php website: <a href="http://www.pinnacleinternet.com/installing-invisible-recaptcha/" rel="nofollow noreferrer">http://www.pinnacleinternet.com/installing-invisible-recaptcha/</a> everything works well. but while implement on multiple forms in a same page then Captcha only work on first form and not sure what’s happening with the second form, I curious to know how its work with multiple forms in a single page.
  Or anyone please suggest a working doc for multiple forms?</p>
  
  <pre><code>//this is @Geordy's javascript portion modified according to jquery.validate
      &lt;script type="text/javascript"&gt;
  
      $().ready(function() {
      var demo1Call = 0;
      var demo2Call = 0;
  
          // validate and submit 1st form
          $("#demo-form1").validate({
              rules: {
  
                    pass: {
                      required: true,
                      pwcheck: true,
                      minlength: 5
                    },
              },
              messages: {
                    pass: {
                      required: "Please provide a password",
                      pwcheck: "&lt;br /&gt;*Minimum length 8&lt;br /&gt;*Maximum length 24&lt;br /&gt;*Atleast a digit&lt;br /&gt;*Atleast an upper case&lt;br /&gt;*Atleast a lowercase&lt;br /&gt;*Atleast a special character from these !@#$%",
                      minlength: "Your password must be at least 5 characters long"
                    },
              },
              success: function(error){
                  console.log("Successfully validated");  
              },
              submitHandler: function(form) {
  
                  demo1Call++;
                  if(demo1Call==1){
                      widgetId1 = grecaptcha.render('recaptcha1', {
                      'sitekey' : '&lt;?php echo $config['client-key']; ?&gt;',
                      'callback' : onSubmit1,
                      'size' : "invisible"
                      });
                  }
                  grecaptcha.reset(widgetId1);
                  grecaptcha.execute(widgetId1);
              },
          });
  
          //validate and submit 2nd form
          $("#demo-form2").validate({
              rules: {
  
                    pass: {
                      required: true,
                      pwcheck: true,
                      minlength: 5
                    },
              },
              messages: {
                    pass: {
                      required: "Please provide a password",
                      pwcheck: "&lt;br /&gt;*Minimum length 8&lt;br /&gt;*Maximum length 24&lt;br /&gt;*Atleast a digit&lt;br /&gt;*Atleast an upper case&lt;br /&gt;*Atleast a lowercase&lt;br /&gt;*Atleast a special character from these !@#$%",
                      minlength: "Your password must be at least 5 characters long"
                    },
              },
              success: function(error){
                  console.log("Successfully validated");  
              },
              submitHandler: function(form) {
  
                  demo2Call++;
                  if(demo2Call==1){
                      widgetId2 = grecaptcha.render('recaptcha2', {
                      'sitekey' : '&lt;?php echo $config['client-key']; ?&gt;',
                      'callback' : onSubmit2,
                      'size' : "invisible"
                      });
                  }
                  grecaptcha.reset(widgetId2);
                  grecaptcha.execute(widgetId2);
              },
          });
  
  
  
      });
  
      $.validator.addMethod("pwcheck", function(value) {
         var pattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%])[0-9A-Za-z!@#$%]{8,24}$/;
         return pattern.test(value);
      });
  
  function onSubmit1(token){
          document.getElementById("demo-form1").submit();
  };
  
  function onSubmit2(token){
          document.getElementById("demo-form2").submit();
  };
  
  &lt;/script&gt;
  </code></pre>