npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

captcha-persion-customize

v1.0.0

Published

React Simple Captcha is a very powerful and easy to use captcha for React JS.

Downloads

1

Readme

React Simple Captcha

React Simple Captcha is a very powerful and easy to use captcha for React JS.

Install

$ npm install react-simple-captcha

Demo
Demo can be seen here.

Usage Guide

  • Step 1:

Import all functions from react-simple-captcha

import { loadCaptchaEnginge, LoadCanvasTemplate, LoadCanvasTemplateNoReload, validateCaptcha } from 'react-simple-captcha';
  • Step 2:

Place < LoadCanvasTemplate /> or < LoadCanvasTemplateNoReload /> (if you do not want 'Reload Captcha' functionality) in your render code

render() {
     return (<div>
        <LoadCanvasTemplate />
         </div>);
 };

OR

render() {
     return (<div>
         <LoadCanvasTemplateNoReload />
         </div>);
 };
  • Step 3:

Paste loadCaptchaEnginge(6) (You can change 6 to number of captcha charcters you want) in componentDidMount

componentDidMount () {
    loadCaptchaEnginge(6); 
 };
  • Step 4:

Validate captcha by using validateCaptcha(user_captcha_value)

<!-- Let's create a function doSubmit() which submit user value onClick() (See Example section below for details) -->  

doSubmit = () => {
<!-- Let's assume there is an HTML input text box with id 'user_captcha_input' to get user input -->   
     let user_captcha_value = document.getElementById('user_captcha_input').value;

     if (validateCaptcha(user_captcha_value)==true) {
         alert('Captcha Matched');
     }

     else {
         alert('Captcha Does Not Match');
     }
 };

OR
If you don't watch captcha to be reloaded if user enter the wrong value then set second parameter to false validateCaptcha(user_captcha_value, false)

<!-- Let's create a function doSubmit() which submit user value onClick() (See Example section below for details) -->  
   
doSubmit = () => {
<! -- Let's assume there is an HTML input text box with id 'user_captcha_input' to get user input -->    
       let user_captcha_value = document.getElementById('user_captcha_input').value;

       if (validateCaptcha(user_captcha_value, false)==true) {
           alert('Captcha Matched');
       }

       else {
           alert('Captcha Does Not Match');
       }
   };

Options

Listed are all the options available for react-simple-captcha

| Name | Description | | ------ | ------ | | < LoadCanvasTemplate /> | It will load the captcha with 'Reload Captcha' functionality. Place between your render code, usage example < LoadCanvasTemplate /> | | < LoadCanvasTemplateNoReload /> | It will load the captcha without 'Reload Captcha' functionality. Place between your render code, usage example < LoadCanvasTemplateNoReload /> | | loadCaptchaEnginge(Number_Of_Captcha_Charcters); | Simply paste it in componentDidMount(). Pass number of captcha characters you want to display. | | validateCaptcha(User_Submitted_Value) | Will return true if user submitted value matches with captcha otherwise false. Also will reload captcha if user submitted value is false | | validateCaptcha(User_Submitted_Value, false) | Will return true if user submitted value matches with captcha otherwise false. Will not reload captcha if user submitted value is false |

Example

Let's create a class name CaptchaTest (and save it as captcha_test.jsx in src folder) with react simple captcha functionality:

import React, { Component } from 'react';
import { loadCaptchaEnginge, LoadCanvasTemplate, LoadCanvasTemplateNoReload, validateCaptcha } from 'react-simple-captcha';



class CaptchaTest extends Component {

   componentDidMount () {
      loadCaptchaEnginge(6); 
   };

   doSubmit = () => {
       let user_captcha = document.getElementById('user_captcha_input').value;

       if (validateCaptcha(user_captcha)==true) {
           alert('Captcha Matched');
           loadCaptchaEnginge(6); 
           document.getElementById('user_captcha_input').value = "";
       }

       else {
           alert('Captcha Does Not Match');
           document.getElementById('user_captcha_input').value = "";
       }
   };

   render() {
        

       return (<div>
           <div className="container">
               <div className="form-group">

                   <div className="col mt-3">
                       <LoadCanvasTemplate />
                   </div>

                   <div className="col mt-3">
                       <div><input placeholder="Enter Captcha Value" id="user_captcha_input" name="user_captcha_input" type="text"></input></div>
                   </div>

                   <div className="col mt-3">
                       <div><button class="btn btn-primary" onClick={() => this.doSubmit()}>Submit</button></div>
                   </div>
                     
               </div>

           </div>
       </div>);
   };
}

export default CaptchaTest;

Import CaptchaTest in index.js

import CaptchaTest from './captcha_test'; 

Now replace ReactDOM.render with

ReactDOM.render(<CaptchaTest />, document.getElementById('root'));

Browser support

Works in every modern browser which has support for canvas element.

License

react-simple-captcha is licensed under the MIT license.

Developer Profile

Name: Masroor Ejaz
Linkedin: https://www.linkedin.com/in/masroorejaz/
Twitter: https://twitter.com/masroorejaz
Note: Feel free to contact me it you have any questions!