-
Notifications
You must be signed in to change notification settings - Fork 38
/
example.html
72 lines (63 loc) · 3.22 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html class="no-js" ng-app="myApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>angular-re-captcha example</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.js"></script>
<script src="../angular-re-captcha.js"></script>
</head>
<body ng-controller="AppCtrl">
<div class="container">
<h1>Example usage</h1>
<div class="alert alert-success" ng-show="showdialog">
<button type="button" class="close" ng-click="showdialog=false" data-dismiss="alert" aria-hidden="true">×</button>
<strong>Yeah, you've submitted the form.</strong>
<br />Now you have to validate the user response on your server. <a href="https://developers.google.com/recaptcha/docs/verify" target="_blank">here is how</a>
</div>
<form name="registerForm" role="form" ng-submit="register()" novalidate>
<div class="form-group" ng-class="{ 'has-error' : registerForm.email.$invalid && !registerForm.email.$pristine }">
<label for="email">Email address*</label>
<input type="email" class="form-control" name="email" ng-model="user.email" required>
<span ng-show="registerForm.email.$invalid && !registerForm.email.$pristine" class="help-block">Please enter your email address</span>
</div>
<div class="form-group">
<label>Captcha*</label>
<div re-captcha ng-model="user.captcha"></div>
</div>
<button type="submit" ng-disabled="registerForm.$invalid" class="btn btn-primary">Create new Account</button>
<form>
</div>
<div class="container">
<h2>Debug output</h2>
<pre>
{{user | json}}
</pre>
</div>
<script>
angular.module('myApp', ['reCAPTCHA'])
.config(function (reCAPTCHAProvider) {
// required, please use your own key :)
reCAPTCHAProvider.setPublicKey('6LfyK-0SAAAAAAl6V9jBGQgPxemtrpIZ-SPDPd-n');
// optional
reCAPTCHAProvider.setOptions({
theme: 'clean'
});
})
.controller('AppCtrl', function ($scope, reCAPTCHA) {
$scope.user = {};
// or you can also set key here
reCAPTCHA.setPublicKey('6LfyK-0SAAAAAAl6V9jBGQgPxemtrpIZ-SPDPd-n');
$scope.register = function () {
if($scope.registerForm.$valid) {
$scope.showdialog = true;
console.log('Form is valid');
}
}
})
</script>
</body>
</html>