How to check in js that user has checked the checkbox in Google recaptcha?

后端 未结 5 2036
清酒与你
清酒与你 2020-12-02 07:33

I have added the following before end of head


I have added th

5条回答
  •  猫巷女王i
    2020-12-02 07:45

    To check if google recaptcha v2 is checked or not you can do it by the following code :

    var checkCaptch = false;
         var verifyCallback = function(response) {
            if (response == "") {
                 checkCaptch = false;
             }
             else {
                 checkCaptch = true;
             }
         };
         $(document).ready(function() {
             $("#btnSubmit").click(function() {
                 if (checkCaptch && grecaptcha.getResponse()!="") {
                      //Write your success code here
                 }
             });
         })
    

提交回复
热议问题