From 548bfc9455c859251d62ba406d1d40135b158f67 Mon Sep 17 00:00:00 2001 From: Jan Koprowski Date: Sun, 13 Sep 2009 07:00:31 +0200 Subject: Autopopulation text form now clear content after getting focus every time. Problem described in #630. --- lib/gallery.form.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/gallery.form.js') diff --git a/lib/gallery.form.js b/lib/gallery.form.js index e69be326..e1a24290 100644 --- a/lib/gallery.form.js +++ b/lib/gallery.form.js @@ -26,16 +26,23 @@ function shortFormInit(formID) { $(inputID).val(labelValue); } + // Attach event listeners to the input - $(inputID).bind("focus blur", function(e){ + $(inputID).bind("focus", function(e){ var eLabelVal = $(this).siblings("label").html(); var eInputVal = $(this).val(); // Empty input value if it equals it's label if (eLabelVal == eInputVal) { $(this).val(""); + } + }); + + $(inputID).bind("blur", function(e){ + var eLabelVal = $(this).siblings("label").html(); + // Reset the input value if it's empty - } else if ($(this).val() == "") { + if ($(this).val() == "") { $(this).val(eLabelVal); } }); -- cgit v1.2.3