title: validate google recapcha client side javascript
body: <p>I'm adding a recapcha v2 to a form. I've searched for how to validate the recapcha via Javascript client side to know if the recapcha has been completed before submitting the form. The form validates false regardless of whether or not the recapcha has been completed.</p>
  <p>what I have tried:</p>
  <pre><code>      var response = grecaptcha.getResponse();
        if(response.length == 0) 
        { 
          //reCaptcha not verified
          alert(&quot;please complete the reCAPCHA. Try Again!&quot;); 
          
          return false;
        }
  </code></pre>
  <p>When I try to alert response, it's blank.  how do I get the code to know that the recapcha has been completed? The Javascript tests the other fields on the form fine.</p>
  <p>I found another form on the site that uses:</p>
  <pre><code>if (grecaptcha.getResponse() == &quot;&quot;){
      alert(&quot;You must complete the recapcha in order to submit the form. Try again.&quot;);
      return false;
  }
  </code></pre>
  <p>This form works as one would expect. I tried adding this validation to the form that does not and it keeps telling me to complete the recapcha even if I have.</p>