reCAPTCHA : Grey out Submit button until backend interaction is finished -
i've integrated recaptcha , working fine, except when users quick click submit button right after checking "i'm not robot" checkbox. takes quite time recaptcha register user action via ajax, , if click on submit quickly, g-recaptcha-response missing, , validation fails.
hence question: how grey out submit button until g-recaptcha-response value available?
<form id="capform" action="/captchaverify" method="post"> <div class="g-recaptcha" data-sitekey="..."></div> <p> <input id="capsubmit" type="submit" value="submit"> </form>
i ended using data-callback
attribute described in documentation:
<form action="/captchaverify" method="post"> <div class="g-recaptcha" data-sitekey="..." data-callback="capenable" data-expired-callback="capdisable"></div> <p> <input id="capsubmit" type="submit" value="submit"> </form>
javascript (mootools-based, general idea should clear):
function capenable() { $('capsubmit').set('disabled', false); } function capdisable() { $('capsubmit').set('disabled', true); } window.addevent('domready', function(){ capdisable(); });
Comments
Post a Comment