1.4.8 • Published 3 years ago
captcha-sveltekit v1.4.8
Sveltekit Captcha
A highly customizable and simple to use Captcha component for SvelteKit.
Installation
npm install captcha-sveltekitUsage
<script>
import Captcha from 'captcha-sveltekit';
const handleValidation = ({detail}) => {
console.log(detail) //true or false
}
</script>
<Captcha
on:captcha-validation={handleValidation}
//other options here
/>Component Properties
| option | type | description | default |
|---|---|---|---|
| inner | HTMLDivElement | binded to the general container | undefined until component is mounted |
| captcha_image | HTMLImageElement | binded to the image element of the captcha | undefined until component is mounted |
| input_text | HTMLInputElement | binded to the input element where user where user writes the captcha result | undefined until component is mounted |
| button | HTMLButtonElement | binded to the button that triggers the captcha verification | undefined until component is mounted |
| captcha | string | the string representing the captcha | "" |
| user_input | string | binded to the value of the input_text | "" |
| char_amount | number | amount of characters to show in the captcha | 5 |
| canvas_width | number | width of the canvas/image | 345 |
| canvas_height | number | height of the canvas/image | 96 |
| background_color | string | background color of the canvas | "#FFF" |
| font | string | font used in the characters of the captcha | "bold 30px Ubuntu" |
| font_color | string | color of the font used in the characters of the captcha | "#777" |
| lines_color | string | color of the lines that strike through the captcha image | "#777" |
| lines_amount | number | amount of lines in the captcha image | 20 |
| captcha_alt | string | captcha image alt | "CAPTCHA" |
| input_placeholder | string | placeholder of the input text | "CAPTCHA" |
| button_text | string | inner text of the button | "Check" |
| case_sensitive_captcha | boolean | wether or not the captcha is case sensitive to the user input | true |
| use_random_font_colors | boolean | wether or not use random colors for each captcha character, if true, overwrites the font_color option | false |
| use_random_line_colors | boolean | wether or not use random colors for each line, if true, overwrites the lines_color option | false |
| autocheck_user_input | boolean | wether or not to check automatically if user input is same as the captcha, if true hides the check button | false |
| auto_disapear | boolean | wether or not auto hide the captcha once is completed | true |
Events
- captcha-validation
- if
autocheck_user_inputisfalse, is dispatched whencheck buttonis clicked, thedetailmight betrueorfalse, depending on whetheruser_inputis correct or not - if
autocheck_user_inputistrue, is dispatched whenuser_inputhas same lenght ascaptchaanduser_inputis correct, thedetailwill be alwaystruein this case
- if
Screenshots
default values

autocheck_user_input=true
.png)
use_random_font_colors=true

use_random_font_colors=true; use_random_line_colors=true
.png)
char_amount=10; line_amount=5; font='Italic 30px Arial'
.png)
Licence
MIT licensed
1.4.8
3 years ago
1.4.7
3 years ago
1.4.6
3 years ago
1.4.5
3 years ago
1.4.4
3 years ago
1.4.3
3 years ago
1.4.2
3 years ago
1.4.1
3 years ago
1.3.12
3 years ago
1.3.11
3 years ago
1.3.10
3 years ago
1.3.9
3 years ago
1.3.8
3 years ago
1.3.7
3 years ago
1.3.6
3 years ago
1.3.5
3 years ago
1.3.4
3 years ago
1.3.3
3 years ago
1.3.0
3 years ago
1.2.3
3 years ago
1.2.2
3 years ago
1.2.1
3 years ago
1.2.0
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago