jquery - Google ReCAPTCHA how to make required? -
does know how make "google recaptcha (v2)" "required" in form
?
i mean no form submission until recaptcha filled-in?
i use parsleyjs in form, didnt find way make work div
s...
you have use recaptcha verify response call back. this: <script src='https://www.google.com/recaptcha/api.js?onload=recaptchacallback&render=explicit'></script>
var rc2key = 'sitekey', dosubmit = false; function recaptchaverify(response) { if (response === document.queryselector('.g-recaptcha-response').value) { dosubmit = true; } } function recaptchaexpired () { /* when expires */ } function recaptchacallback () { /* must in global scope google access */ grecaptcha.render('id', { 'sitekey': rc2key, 'callback': recaptchaverify, 'expired-callback': recaptchaexpired }); } document.forms['form-name'].addeventlistener('submit',function(e){ if (dosubmit) { /* submit form or else */ } })
Comments
Post a Comment