home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (captcha.js)

This example Drupal source code file (captcha.js) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

autocomplete, checked, click, context, edit-captcha-add-captcha-description, edit-captcha-description-wrapper, edit-captcha-response, function, hide, if, is, php, show, slow

The captcha.js Drupal example source code

// $Id: captcha.js,v 1.2.2.3 2011/02/06 20:45:12 soxofaan Exp $

// Javascript behaviors for general CAPTCHA functionality.
Drupal.behaviors.captcha = function (context) {

  // Turn off autocompletion for the CAPTCHA response field.
  // We do it here with Javascript (instead of directly in the markup)
  // because this autocomplete attribute is not standard and
  // it would break (X)HTML compliance.
  $("#edit-captcha-response").attr("autocomplete", "off");

};


// JavaScript behaviors for the CAPTCHA admin page
Drupal.behaviors.captchaAdmin = function (context) {

	// Add onclick handler to checkbox for adding a CAPTCHA description
	// so that the textfields for the CAPTCHA description are hidden
	// when no description should be added.
	$("#edit-captcha-add-captcha-description").click(function() {
		if ($("#edit-captcha-add-captcha-description").is(":checked")) {
			// Show the CAPTCHA description textfield(s).
			$("#edit-captcha-description-wrapper").show("slow");
		}
		else {
			// Hide the CAPTCHA description textfield(s).
			$("#edit-captcha-description-wrapper").hide("slow");
		}
	});
	// Hide the CAPTCHA description textfields if option is disabled on page load.
	if (!$("#edit-captcha-add-captcha-description").is(":checked")) {
		$("#edit-captcha-description-wrapper").hide();
	}

};

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal captcha.js source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.