Show content after captcha submit

15 views Asked by At

i want text content on page to be displayed after captcha submit, it can be simply by change by java script or any display: none to display: flex or something similar. who can help with such functionality ? i tried few java script options something like

<div id="captcha-container">
    [bws_google_captcha]
</div>

<div id="hidden-content" style="display: none;">
    <p>hidden contentь</p>
</div>

<button id="show-content-button" onclick="showContent()">show content</button>


<script src="https://www.google.com/recaptcha/api.js?render=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"></script>


<script>
    document.addEventListener('DOMContentLoaded', function () {
        grecaptcha.ready(function () {
            grecaptcha.execute({ action: 'homepage' }).then(function (token) {
                document.getElementById('captcha-container').innerHTML = '<input type="hidden" name="g-recaptcha-response" value="' + token + '">';
            });
        });
    });

    function showContent() {
        var captchaInput = document.querySelector('input[name="g-recaptcha-response"]');
        if (captchaInput && captchaInput.value) {
            document.getElementById('hidden-content').style.display = 'block';
        } else {
            console.error('error captcha submit');
        }
    }
</script>
0

There are 0 answers