Hi Karl,

 

Cool revision, Karl. and I'm all good, pal. I actually did the same thing
when I saw Scott's post. did something with a bit just for kicks to see if
it can be done another way. Constructive feedback is always healthy. I
definitely think we all need to challenge each other or play each other
devil's advocate so we can crank out better, shorter scripts.  Doing so, we
might even have a chance to solve world hunger all in just 5 lines of jQuery
code.

 

Cheers, and have a great week ahead.

 

Michael

 

 

  _____  

From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Karl Swedberg
Sent: Sunday, April 01, 2007 6:16 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: My first plugin, overlabel

 

Hi Michael, 

 

That looks like it would do what you're shooting for. 

 

I played around with it a bit just for kicks, seeing if I could condense
things, and came up with this:

 

$('#userid_field,#password_field').focus(function() {

$(this).attr({ class: 'login_fields'}).val('');

if ($(this).is('#password_field')) {

$(this).attr('type', 'password');

};

}).blur(function() {

if ( !$.trim($(this).val()) && $(this).is('#userid_field') ) {

$(this).attr('class', 'login_labels').val('userid');

} else if ( !$.trim($(this).val()) && $(this).is('#password_field') ) {

$(this).attr({ class: 'login_labels', type: 'text'}).val('password');

};

});

 

I personally still prefer the approach that uses labels (and actually wrote
up my own little script doing the same thing for the book) for the
accessibility and graceful degradation, but I guess I could see a place for
both. 

 

One other thing that you might want to consider is that your script empties
the inputs even after a user has typed in something and then returns to it.
This might prove frustrating to someone who types in a long user name, sees
a typo, and returns to the field to fix it, only to find that the user name
is wiped out and he or she has to start all over again. On focus, you might
want to check for this.value == this.defaultValue or something of the sort.

 

I'm hoping you'll take this all as constructive feedback. :)



 

Cheers, 

 

--Karl

_________________

Karl Swedberg

www.englishrules.com

www.learningjquery.com

 





 

On Apr 1, 2007, at 5:39 PM, Michael E. Carluen wrote:





Hi Scott, Karl:

Below, is a revised version of the script I sent earlier that addresses the
blur event.

I frequently require Javascript enabled as a minimum, that is why I often
regret to remember about graceful degradation. In any case Scott, your
plugin definitely is more flexible, I agree. - Michael

.login_labels{color: #708090;}

Reply via email to