A "Completely Automated Public Turing test to tell Computers and Humans Apart" aka CAPTCHA, build on JavaScript. Simple integration to prevent bots from submiting your form
##FEATURE
- Control on number of wrong attempt (Reloads the page on attempt expires)
- Auto reload captcha after specific interval
- Shortcut detection, i.e. reloads captcha if any shortcut is detected (like ctrl + V or RightClick + paste)
##CONTENT
PLEASE NOTE
encaptcha.min.js
and encaptcha.js
in directory /dist
is always a stable version of en-captcha
- Clone/Download the repo in your local system
- Extract the
encaptcha.min.js
orencaptcha.js
from the dir/dist
and put it your project - Once you already have the plugin (the
.js
file) in your project - Write a script to configure and display the captcha. To do so (Refer the Example given below )
- Create an
Encaptcha
object sayen-obj
and pass in theconfiguration
explained below in CONFIGURATION section - Execute
en-obj.run()
to start the captcha.
$(document).ready(function(){
var obj = new Encaptcha({
config:{
container: '#captcha2',
reload_interval: 70,
themeColorHex: '#E6E6E6',
reloadBtn_text: '<i class="fa fa-refresh" aria-hidden="true"></i> Refresh',
allowed_attempt: 5,
form: '#form1'
},
onSuccess: function(){
console.log("YAY! success")
},
onFailure: function(){
console.log('Hi I might be a robot~ T_T ')
}
});
});
char_count:
Strength of CAPTCHA (ie number of letters in CAPTCHA image). Recommended-value: 5 or 6 . It cannot be less than 5container:
DOM element where you want the CAPTCHA to be displayed. Value can beid
orclass
of the element. Please make sure this CAPTCHA container is empty. Example value:'#container'
or'.container'
.reload_interval:
[OPTIONAL] The CAPTCHA must reload after certain seconds so this value should contain an integer. Recommended-value: 30 or 60. Default is 45allowed_attempt:
[OPTIONAL] Number of times a user is allowed to enter wrong CAPTCHA. Accepts a number. Default - infiniteonSuccess:
[OPTIONAL] The value has to be an anonymous function which will execute when the CAPTCHA is successfully validated.onfailure:
[OPTIONAL] The value has to be an anonymous function which will execute when the CAPTCHA validation FAILS each time.form:
[OPTIONAL] This value has be the form identifier which you want to protect from bots. Example: '#form_id' or '.form_class'
Tested in all modern browser ( Chrome, Opera, FF, Safari ) Doesnt work in old IE
NO Dependency. Though it is not dependent on any 3rd party library or framework, but if you are using enCAPTCHA on any form which is NOT asynchronously submitted, it is recommended to have jQuery, will add an extra layer of security to enCAPTCHA.
##Resources##
- Online Image Cropping
- Online Sprite generator
- Online OCR
- Online Image compress
- Online Image metadata viewer
- Online Base64
##CONTENT
- Intro
- Setup-guide
- Example
- Configuration / Options
- [Dependency] (#dependency)
- Browser support