Posted By

zackfern on 06/23/11


Tagged

logic Captcha addition arithmetic


Versions (?)

Addition CAPTCHA


 / Published in: jQuery
 

  1. function random_between(to, from) {
  2. return Math.floor(Math.random() * (to - from + 1) + from);
  3. }
  4. $(document).ready(function() {
  5. var num1 = random_between(0,5)
  6. var num2 = random_between(5,10);
  7. $('label[for="captcha"]').text("What is "+num1+" + "+num2);
  8. $('form').submit(function() {
  9. if($('#captcha').val() == (num1+num2)) {
  10. $('form').submit();
  11. }
  12. else {
  13. alert("Your CAPTCHA IS NOT valid!");
  14. return false;
  15. }
  16. });
  17. });

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: verostudios on June 24, 2011

captcha as a JS variable where a bot can access it sort of defeats the whole point of the system...

You need to login to post a comment.