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

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

I have added the following before end of head


I have added th

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 07:48

    Let the browser do the job for you! (based on slinky2000 answer)

    note: this is only to prevent sending an 'accidentally' unchecked recaptcha. You still have to verify the recaptcha on server side because a bot does not care ...

    Add a an invisible input tag with required=true attribute just below the div.g-recaptcha.

    
    

    Enclose both width a div with position=relative; to point the bottom:0; above to the bottom of recaptcha.

    Now the Browser asks nicely to fill out this field - pointing to the recapcha.

    Now we need the callback:

    and

    function recaptchaCallback() { 
        $('#recaptcha_check_empty').val(1);
    }
    

提交回复
热议问题