Advertisement
chrishajer

Change color of text for completed placeholder fields

Oct 22nd, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* http://www.gravityhelp.com/forums/topic/font-color-change-input-fields */
  2. /* working example: http://gravity.chrishajer.com/census/ */
  3.  
  4. jQuery(document).ready(function() {
  5.  
  6.     jQuery.fn.cleardefault = function() {
  7.     return this.focus(function() {
  8.         if( this.value == this.defaultValue ) {
  9.             this.value = "";
  10.             jQuery(this).removeClass('incomplete').addClass('complete');
  11.         }
  12.     }).blur(function() {
  13.         if( !this.value.length ) {
  14.             this.value = this.defaultValue;
  15.             jQuery(this).removeClass('complete').addClass('incomplete');
  16.         }
  17.     });
  18. };
  19. jQuery(".clearit input, .clearit textarea").cleardefault();
  20.  
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement