1.0.4 • Published 7 months ago

@berlinsms/captcha-wrapper v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

jQuery CaptchaWrapper

Homepage

Description

This captcha wrapper makes it easy to include multiple types of captcha on your site.

This can be helpful if, for example, you want to let your customers choose the type of captcha.

The libraries of the unused captchas are not loaded.

Usage

Include jquery

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

Download bsms-captcha-wrapper

https://static.berlinsms.de/toolsforcoder/captcha-wrapper/dist/bsms-captcha-wrapper.min.js

Include bsms-captcha-wrapper

<script src="bsms-captcha-wrapper.min.js"></script>

Find your jquery-container and assign captcha-wrapper

$('.plugin-container').bsmsCaptchaWrapper();    

Make sure, the script is fully loaded, before you assign captcha-wrapper, e.g. use jquerys 'ready'

$(document).ready(function () {
    $('.plugin-container').bsmsCaptchaWrapper();
});    

Provide options:

$(document).ready(()=>{
    $('.plugin-container').bsmsCaptchaWrapper( { sitekey:'asdfghjklasdfghjkl' } );
});    

Provide callbacks:

$(document).ready(function () {
    $('.plugin-container')
        .bsmsCaptchaWrapper( { sitekey:'asdfghjklasdfghjkl' } )
        .onSolved(captchaSolved)
        .onExpired(captchaExpired);
});    
function captchaSolved(token) {
    alert(`Captcha solved with token=${token}`);
}
function captchaExpired() {
    alert(`Captcha expired`);
}

Options

OptionDESCRIPTIONDEFAULT
captchaTypeType of captcha used. Feel free to add more types of captchasreCaptcha
sitekeySitekey of recaptcha or hcaptcha or anycaptcha
onLoadCallback that fires when the captcha has loadednull
onSolvedCallback that is triggered when the captcha has been solvednull
onExpiredCallback triggered when the captcha expiresnull
onErrorCallback, will be triggered, if something is wrongnull