3 * https://github.com/AbleTech/jquery.placeholder-label
5 * Copyright (c) 2010 Able Technology Consulting Limited
6 * http://www.abletech.co.nz/
10 placeholder_class
: null,
11 add_placeholder: function(){
12 if($(this).val() == $(this).attr('placeholder')){
13 $(this).val('').removeClass($.placeholderLabel
.placeholder_class
);
16 remove_placeholder: function(){
17 if($(this).val() == ''){
18 $(this).val($(this).attr('placeholder')).addClass($.placeholderLabel
.placeholder_class
);
21 disable_placeholder_fields: function(){
22 $(this).find("input[placeholder]").each(function(){
23 if($(this).val() == $(this).attr('placeholder')){
32 $.fn
.placeholderLabel = function(options
) {
33 // detect modern browsers
34 var dummy
= document
.createElement('input');
35 if(dummy
.placeholder
!= undefined){
40 placeholder_class
: 'placeholder'
43 if(options
) $.extend(config
, options
);
45 $.placeholderLabel
.placeholder_class
= config
.placeholder_class
;
47 this.each(function() {
50 input
.focus($.placeholderLabel
.add_placeholder
);
51 input
.blur($.placeholderLabel
.remove_placeholder
);
53 input
.triggerHandler('focus');
54 input
.triggerHandler('blur');
56 $(this.form
).submit($.placeholderLabel
.disable_placeholder_fields
);