I have some problems with the browser Chrome, when it remembers password, username, etc. I cannot check if the input field is empty. I use the following code, but the if statement doesn't work in Chrome while it works in all other browsers.
$(document).ready(function() {    
    $('.inputWithLabel').each(function(){
        if ($(this).val().length != 0){
            var element_id = $(this).attr('id');
            $('label[for="' + element_id + '"]').addClass('inputWithText');
        }
    });
});
I tried to alter the following labels
<form action="" method="post">
    <div class="divInputLabel inputLabel">
        <label class="labelInput" for="username">Brugernavn*</label>
        <input class="inputLabel inputWithLabel" id="username" name="username" type="text">
    </div>
    <div class="divInputLabel inputLabel">
        <label class="labelInput" for="password">Adgangskode*</label>
        <input class="inputLabel inputWithLabel" id="password" name="password" type="password">
    </div>
    <div class="divInputLabel inputLabel">
        <label class="labelInput" for="password_again">Gentag adgangskode*</label>
        <input class="inputLabel inputWithLabel" id="password_again" name="password_again" type="password">
    </div>
    <div class="divInputLabel inputLabel">
        <label class="labelInput" for="first_name">Fornavn*</label>
        <input class="inputLabel inputWithLabel" id="first_name" name="first_name" type="text">
    </div>
    <div class="divInputLabel inputLabel">
        <label class="labelInput" for="last_name">Efternavn</label>
        <input class="inputLabel inputWithLabel" id="last_name" name="last_name" type="text">
    </div>
    <div class="divInputLabel inputLabel">
        <label class="labelInput" for="email">Email*</label>
        <input class="inputLabel inputWithLabel" id="email" name="email" type="text">
    </div>
    <div class="divInputLabel inputLabel">
        <input type="Submit" class="submit-button" value="Registre">
    </div>
</form>
I hope someone can help me.
 
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    