I've made a login form which contains the labels for 'username' and 'password', with the below jquery used to hide the labels once the user focuses on the field.
$(document).ready(function(){
$("form.login input")
.bind("focus.labelFx", function(){
$(this).prev().hide();
})
.bind("blur.labelFx", function(){
$(this).prev()[!this.value ? "show" : "hide"]();
})
.trigger("blur.labelFx");
});
and the html:
<form method="post" id="login-form" action="/accounts/login/">
<div class="input-wrapper">
<label for="id_username">Username</label>
<input id="id_username" size="30" type="text" name="username">
</div>
</form>
The problem is that chrome's autocomplete appears to be loading the username and password before this scrip can catch it, giving me strangely overlapping text until I manually focus on it. This is not a problem with Firefox. Pic: https://i.stack.imgur.com/nZXji.jpg
Any suggestions on how to fix this so that autofilled data causes the labels to hide?