开发者

Implementing reCaptcha with jQuery

开发者 https://www.devze.com 2023-02-20 18:58 出处:网络
I\'m trying to use reCaptcha in a dynamic form of mine. At the simplest开发者_JAVA百科 level, I want the form to not go through if the reCaptcha is invalid. Here\'s the part of the code that will post

I'm trying to use reCaptcha in a dynamic form of mine. At the simplest开发者_JAVA百科 level, I want the form to not go through if the reCaptcha is invalid. Here's the part of the code that will post the form:

if($("#registerPost").valid() && /*reCaptcha valid*/)
{
    $.post('php/registerPost.php', $('#registerPost').serialize(), function(data){
        window.location.replace("mainpage");
    }
}

I also would need to show a div if the reCaptcha is put through and returned invalid, but I know how to do that.

So my question is - how can I display a reCaptcha and have it check itself, all dynamically without a page refresh, like the rest of my form, and then if it is valid, to have a boolean be true, and if invalid, to have a boolean be false?


I would make an ajax call to verify the correctness of re-captcha and based on the return value, I would decide on, if I need to post the form.

0

精彩评论

暂无评论...
验证码 换一张
取 消