jQuery default/placeholder input text and problems with saved information
Posted
by user318106
on Stack Overflow
See other posts from Stack Overflow
or by user318106
Published on 2010-04-16T00:50:37Z
Indexed on
2010/04/16
0:53 UTC
Read the original article
Hit count: 336
Hey Guys,
I'm new to jQuery and have an annoying problem. I have some login fields that are filled with default text when the field is empty and then removed when clicked.
My problem is that when the user has their username/password saved (with browser), if they return to the page the login fields are filled with the users saved input as well as the default input.
$('#login input.text').each(function(i, field) {
field = $(field);
if (field.val().length > 0) {
field.prev().css('display', 'none');
}
field.focus(function() {
field.prev().css('display', 'none');
}).blur(function() {
if (field.val() == '') field.prev().css('display', 'block');
});
})
© Stack Overflow or respective owner