Loads current ReCaptcha version using an intelligent import and a <div>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Usage: | |
* - import jQuery; | |
* - import this; | |
* - create an element (maybe a div) with id="js-reCaptchaContainer" and data-publickey="<your public key>" | |
* ex: <div id="js-reCaptchaContainer" data-publickey="6LfSXd4SAAAAAH0wvCuC164"></div> | |
*/ | |
if (this.jQuery) { | |
jQuery(document).ready(function ($) { | |
var el = $('#js-reCaptchaContainer'); | |
if (el.length && el.data('publickey')) { | |
$.ajax({ | |
url: "http://www.google.com/recaptcha/api/js/recaptcha_ajax.js", | |
dataType: "script", | |
cache: true | |
}).done(function (script, textStatus) { | |
Recaptcha.create(el.data('publickey'), "js-reCaptchaContainer", { | |
theme: "clean", | |
lang: "pt", | |
callback: Recaptcha.focus_response_field | |
}); | |
}).fail(function (jqxhr, settings, exception) { | |
// fail message | |
}); | |
} | |
}); | |
} else { | |
alert('Recaptcha loader requires jQuery'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment