JQuery Plugin Repository

Close Complete List of Plugins

toggleActive  |  Category: Forms  |  Modified: 11 Aug 2009  |  Enhance appearance of focused form fields, and toggle display of default values.

This plugin is applied to one or more form elements to provide visual feedback, and toggle the default value, when the specified field receives and loses keyboard focus.

Summary

Script File

jq.toggleActive.js ( view )

Available Options

focusBG

A string specifying the form element's background color when focused. Default value is "#F5F5F5".

focusFG

A string specifying the form element's foreground (text) color when focused. Default value is "#000".

blurBG

A string specifying the form element's background color when not focused. Default value is "#FFF".

blurFG

A string specifying the form element's foreground (text) color when not focused. Default value is "#666".

toggleVal

Boolean indicating whether to toggle the default value of the form field as the field is cleared and loses focus. This is most useful for fields that have a full or partial default value assigned to them. Default value is false.

Basic Usage

$("ELEMENT").toggleActive();

$("ELEMENT").toggleActive({ options });

Minimum Browser Support

  • Apple Safari 3
  • Google Chrome 1
  • Microsoft Internet Explorer 6
  • Mozilla Firefox 3
  • Opera 9

Example 1

This example uses the default settings.

Associated Code

<script type="text/javascript">
$(document).ready(function() {
  $("#txtName1, #selRank1").toggleActive();
  });
</script>

Example 2

This example uses the default settings for appearance, but sets toggleVal to true, so that the default value of the form field is displayed when the field is cleared and no longer focused.

Associated Code

<script type="text/javascript">
$(document).ready(function() {
  $("#txtURL2").toggleActive({;
    toggleVal : true
    });
  });
</script>

Example 3

This example overrides the default settings for focused appearance, and sets toggleVal to true as in Example 2 above.

Associated Code

<script type="text/javascript">
$(document).ready(function() {
  $("#txtName3, #selRank3, #txtURL3").toggleActive({;
    focusBG   : "#F0F9F3",
    focusFG   : "#093",
    toggleVal : true
    });
  });
</script>

JQuery Plugin Repository | Home | Print

back to ksscholl.com