Posted By


zackfern on 06/23/11

Tagged


Statistics


Viewed 514 times
Favorited by 0 user(s)

Addition CAPTCHA


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  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

You need to login to post a comment.