/lib/jquery-validate/demo/captcha/captcha.js

# · JavaScript · 27 lines · 25 code · 2 blank · 0 comment · 0 complexity · 02a6ed487354e9161f816f0c269c4819 MD5 · raw file

  1. $(function(){
  2. $("#refreshimg").click(function(){
  3. $.post('newsession.php');
  4. $("#captchaimage").load('image_req.php');
  5. return false;
  6. });
  7. $("#captchaform").validate({
  8. rules: {
  9. captcha: {
  10. required: true,
  11. remote: "process.php"
  12. }
  13. },
  14. messages: {
  15. captcha: "Correct captcha is required. Click the captcha to generate a new one"
  16. },
  17. submitHandler: function() {
  18. alert("Correct captcha!");
  19. },
  20. success: function(label) {
  21. label.addClass("valid").text("Valid captcha!")
  22. },
  23. onkeyup: false
  24. });
  25. });