Multiple reCAPTCHAs in one ASP.Net page

前端 未结 6 1479
太阳男子
太阳男子 2021-01-18 13:27

It is possible to add multiple reCAPTCHAS in one form? I tried doing so, even giving the multiple reCAPTCHAS different IDs, but when I load the page in the browser, only one

6条回答
  •  醉话见心
    2021-01-18 14:14

    I was initially lead by this thread to believe there is no simple answer, but after digging through the Recaptcha ajax library I can tell you this isn't true! TLDR, working jsfiddle: http://jsfiddle.net/Vanit/Qu6kn/

    It's possible to overwrite the Recaptcha callbacks to do whatever you want with the challenge. You don't even need a proxy div because with the overwrites the DOM code won't execute. Call Recaptcha.reload() whenever you want to trigger the callbacks again.

    function doSomething(challenge){
        $(':input[name=recaptcha_challenge_field]').val(challenge);
        $('img.recaptcha').attr('src', '//www.google.com/recaptcha/api/image?c='+challenge);
    }
    
    //Called on Recaptcha.reload()
    Recaptcha.finish_reload = function(challenge,b,c){
        doSomething(challenge);
    }
    
    //Called on page load
    Recaptcha.challenge_callback = function(){
        doSomething(RecaptchaState.challenge)
    }
    
    Recaptcha.create("YOUR_PUBLIC_KEY");
    

提交回复
热议问题