(function ($) { $.fn.updnWatermark = function (options) { options = $.extend({}, $.fn.updnWatermark.defaults, options); return this.each(function () { var $input = $(this); var $watermark = $input.data("updnWatermark"); if (!$watermark && this.title) { var $watermark = $("<span/>").addClass(options.cssClass).insertBefore(this).hide().bind("show", function () { $(this).children().fadeIn("fast") }).bind("hide", function () { $(this).children().hide() }); $("<label/>").appendTo($watermark).text(this.title).attr("for", this.id); $input.data("updnWatermark", $watermark) } if ($watermark) { $input.focus(function (ev) { $watermark.trigger("hide") }).blur(function (ev) { if (!$(this).val()) { $watermark.trigger("show") } }); if (!$input.val()) { $watermark.show() } } }) }; $.fn.updnWatermark.defaults = { cssClass: "updnWatermark" }; $.updnWatermark = { attachAll: function (options) { $("input:text[title!=''],input:password[title!=''],textarea[title!='']").updnWatermark(options) } } })(jQuery);// $(document).ready(function () { $.updnWatermark.attachAll() });
