Git Product home page Git Product logo

angular-re-captcha's Introduction

angular-re-captcha Bower version Build Status

Integrate reCAPTCHA into angularjs with form validation support.

Install

Install via bower:

bower install angular-re-captcha --save

Include the file into your application:

<script type="text/javascript" src="bower_components/angular-re-captcha/angular-re-captcha.js"></script>

Usage Example

Your can have a look at the example. Basically you have to add reCAPTCHA to your dependencies, configure your key.

angular.module('myApp', ['reCAPTCHA'])
       .config(function (reCAPTCHAProvider) {
            // required: please use your own key :)
            reCAPTCHAProvider.setPublicKey('---KEY---');
            
            // optional: gets passed into the Recaptcha.create call
            reCAPTCHAProvider.setOptions({
                theme: 'clean'
            });
        })
        .controller('AppCtrl', function ($scope, reCAPTCHA) {

            // or you can also set key here
            reCAPTCHA.setPublicKey('---KEY---');

       });

and use the directive within a form. Make sure to set a ng-model

<form name="registerForm" role="form" novalidate>
    <div re-captcha ng-model="user.captcha"></div>
    <button type="submit" ng-disabled="registerForm.$invalid">Submit</button>
</form>

API

reCAPTCHAProvider

reCAPTCHAProvider.setPublicKey()

Type: function
Default: null

Sets the PublicKey

reCAPTCHAProvider.setOptions()

Type: function
Default: null

Sets the options, that get passed into the Recaptcha.create call. Here are a list of the available options

reCAPTCHA

reCAPTCHA.setPublicKey()

Type: function Default: null

Sets the PublicKey

Custom Themes

Custom themes configure recaptcha to use existing elements instead of injecting elements for you. Refer to https://developers.google.com/recaptcha/docs/customization for additional documentation and example widgets.

// Configure the template to use a custom widget.
reCAPTCHAProvider.setOptions({
    theme: 'custom',
    custom_theme_widget: 'recaptcha_widget' // The id of your widget element.
});    
<div re-captcha ng-model="user.captcha" id="recaptcha_widget" style="display:none">
    <div id="recaptcha_image"></div>
    <img id="recaptcha_logo" alt="" src="https://www.google.com/recaptcha/api/img/clean/logo.png">
    <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" />
</div>

Contribute

Pull requests are welcome. Please make sure that you include tests in your PR.

License

MIT License

angular-re-captcha's People

Contributors

bartekn avatar cameri avatar heliocaruccio avatar madvas avatar qnub avatar quodt avatar steffenmllr avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.