title: how to fix 'captcha validation is required' error in c#
body: <p>After checking the i'm not a robot checkbox on validation, there's a java script alert "localhost:12345 says null" then when i click "OK" on the alert then go to click the submit button, still says "Captcha validation is required" even after i validated.</p>
  
  <p>This is for my contact us page, validation won't work even after i got new keys which initially i thought were the problem.
  C#</p>
  
  <pre><code>public partial class _default : System.Web.UI.Page
      {
          classes.Common xCommon = new classes.Common();
          classes.Email xEmail = new classes.Email();
  
          protected static string ReCaptcha_Key = "6LczL3QUAAAAAGnY8hnA-hgRjHV0q---------";
          protected static string ReCaptcha_Secret = "6LczL3QUAAAAADWlVe0IKVERdq----------";
  
          protected void Page_Load(object sender, EventArgs e)
          {
  
          }
  
          protected void btn_Contact_Submit_Click(object sender, EventArgs e)
          {
              xEmail.ContactUs_Email(txt_Contact_Name.Text, txt_Contact_Email.Text, txt_Contact_No.Text, ddl_Branch.SelectedItem.ToString(), ddl_Division.SelectedValue,ddl_Type.SelectedValue,txt_Contact_Message.Text, ddl_Branch.SelectedValue);
  
              ltr_MessageReturn.Text = xCommon.Return_Message("contactus", "");
              btn_Contact_Submit.Visible = false;
          }
  
          [WebMethod]
          public static string VerifyCaptcha(string response)
          {
              string url = "https://www.google.com/recaptcha/api/siteverify?secret=" + ReCaptcha_Secret + "&amp;response=" + response;
              return (new WebClient()).DownloadString(url);
          }
      }
  }
  </code></pre>
  
  <p>JavaScript</p>
  
  <pre><code> var onloadCallback = function () {
      grecaptcha.render('dvCaptcha', {
          'sitekey': '&lt;%=ReCaptcha_Key %&gt;',
          'callback': function (response) {
              $.ajax({
                  type: "POST",
                  url: "default.aspx/VerifyCaptcha",
                  data: "{response: '" + response + "'}",
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: function (r) {
                      var captchaResponse = jQuery.parseJSON(r.d);
                      if (captchaResponse.success) {
                          $("[id*=txtCaptcha]").val(captchaResponse.success);
                          $("[id*=rfvCaptcha]").hide();
                      } else {
                          $("[id*=txtCaptcha]").val("");
                          $("[id*=rfvCaptcha]").show();
                          var error = captchaResponse["error-codes"][0];
                          $("[id*=rfvCaptcha]").html("RECaptcha error. " + error);
                      }
                  }
              });
          }
      });
  };
   &lt;/script&gt;
  </code></pre>
  
  <p>I expect the validation to pass after a user has selected all the required images to pass validation, and then submitted. but the output still says validation required.</p>