Search code examples
jquerycloudflare-turnstile

Cloudflare turnstile captcha language and theme settings with jQuery


I am trying ti implement the Cloudflare turnstile Captcha on my webpage using jQuery. I need to modify the theme and language of the captcha. I added the properties language and theme as described on the documentation page however they dont seem to work like below:

window.onloadTurnstileCallback = function () {
    function show_button() {
        console.log("Render value is " + render);
        if(render) {
            $('#login').prop("disabled", false);
        }
    }

    window.setTimeout(show_button, 3000);

    var render = turnstile.render('#example-container', {
        language: 'fr',
        theme: 'light',
        sitekey: 'ABCD',
        callback: function(token) {
            console.log(`Challenge Success ${token}`);
        },
    });

};

Are these settings only available in the pro version?


Solution

  • I found the answer, rather than using properties in jQuery you have to configure them using html like: <div id="example-container" data-theme="light" data-language="fr" class="cf-turnstile" data-sitekey=""></div>