Created
July 10, 2014 04:35
-
-
Save DarkLotus/8c703ce3ecbc174d95ad to your computer and use it in GitHub Desktop.
Contact Enhanced Math Captcha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery(document).ready(function($){ | |
| var mathenticate = { | |
| bounds: { | |
| lower: 5, | |
| upper: 50 | |
| }, | |
| first: 0, | |
| second: 0, | |
| generate: function () { | |
| this.first = Math.floor(Math.random() * this.bounds.lower) + 1; | |
| this.second = Math.floor(Math.random() * this.bounds.upper) + 1; | |
| }, | |
| show: function () { | |
| return this.first + ' + ' + this.second; | |
| }, | |
| solve: function () { | |
| return this.first + this.second; | |
| } | |
| }; | |
| mathenticate.generate(); | |
| var $auth = $('<input type="text" name="auth" />'); | |
| $auth.attr('placeholder', mathenticate.show()) | |
| .insertAfter('textarea[name="message"]'); | |
| $('form[name="emailForm"]').on('submit', function (e) { | |
| if ($auth.val() != mathenticate.solve()) { | |
| e.preventDefault(); | |
| alert('wrong answer!'); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment