captcha.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (function ($) {
  2. Drupal.behaviors.captcha = {
  3. attach: function (context) {
  4. // Turn off autocompletion for the CAPTCHA response field.
  5. // We do it here with JavaScript (instead of directly in the markup)
  6. // because this autocomplete attribute is not standard and
  7. // it would break (X)HTML compliance.
  8. $("#edit-captcha-response").attr("autocomplete", "off");
  9. }
  10. };
  11. Drupal.behaviors.captchaAdmin = {
  12. attach: function (context) {
  13. // Add onclick handler to checkbox for adding a CAPTCHA description
  14. // so that the textfields for the CAPTCHA description are hidden
  15. // when no description should be added.
  16. // @todo: div.form-item-captcha-description depends on theming, maybe
  17. // it's better to add our own wrapper with id (instead of a class).
  18. $("#edit-captcha-add-captcha-description").click(function() {
  19. if ($("#edit-captcha-add-captcha-description").is(":checked")) {
  20. // Show the CAPTCHA description textfield(s).
  21. $("div.form-item-captcha-description").show('slow');
  22. }
  23. else {
  24. // Hide the CAPTCHA description textfield(s).
  25. $("div.form-item-captcha-description").hide('slow');
  26. }
  27. });
  28. // Hide the CAPTCHA description textfields if option is disabled on page load.
  29. if (!$("#edit-captcha-add-captcha-description").is(":checked")) {
  30. $("div.form-item-captcha-description").hide();
  31. }
  32. }
  33. };
  34. })(jQuery);