diff --git a/docs/static/subscribe.js b/docs/static/subscribe.js index 9e11170..bcf3635 100644 --- a/docs/static/subscribe.js +++ b/docs/static/subscribe.js @@ -16,6 +16,12 @@ document$.subscribe(function prepareSubForm() { formParentDiv.classList.toggle("hidden"); } + function renderCaptcha() { + captchaWidget = hcaptcha.render(hcaptchaDivId, { + sitekey: hcaptchaSiteKey, + }); + } + function subscribeButtonSubmit(event) { event.preventDefault(); @@ -28,9 +34,11 @@ document$.subscribe(function prepareSubForm() { }); if (hcaptcha.getRespKey().length == 0) { - captchaWidget = hcaptcha.render(hcaptchaDivId, { - sitekey: hcaptchaSiteKey, - }); + renderCaptcha(); + return; + } + + if (hcaptcha.getResponse().length == 0) { hcaptcha.execute(captchaWidget); return; } @@ -47,7 +55,6 @@ document$.subscribe(function prepareSubForm() { submitInfo.classList.add("md-banner--warning"); submitInfo.innerHTML = "Subscription failed. Please try again."; hcaptcha.reset(captchaWidget); - document.getElementById(hcaptchaDivId).innerHTML = ""; } }; xhr.send(formData); diff --git a/overrides/partials/subscription-form.html b/overrides/partials/subscription-form.html index 328199b..5383a6f 100644 --- a/overrides/partials/subscription-form.html +++ b/overrides/partials/subscription-form.html @@ -3,7 +3,7 @@