Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome value on load

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.

like image 768
user3805674 Avatar asked Jul 30 '14 12:07

user3805674


People also ask

What is Chrome app ID?

To find an app or extension ID: Open the Chrome Web Store. Find and select the app or extension you want. Look at the URL. The ID is the long string of characters at the end of the URL.

Are Chrome extensions user specific?

Short answer: As long as you install a Chrome extension from the Chrome Web Store and do not explicitly install a separate standalone binary, then the extension is, by default, trapped within the browser profile and cannot access nor modify other Chrome users.

How do I check Chrome memory usage?

Press Shift+Esc on a Chrome tab to open the Chrome Task Manager. You will see processes like Utility, Tab, Subframe, Rendere, Extensions, and so on. On the right side, you will find a memory footprint. This number indicates the RAM usage.

How do I increase Chrome memory?

Give Chrome more system memory Changing a little-known Chrome setting can speed it up by giving it more of your system memory. First, type this into the address bar: chrome://flags/#max-tiles-for-interest-area. Then change the default to 512. That's it.


1 Answers

Try the following code:

    $(document).ready(function() {
      $('body .inputWithLabel').each(function(){
        if ($(this).val().length != 0){
          var element_id = $(this).attr('id');
          $('label[for="' + element_id + '"]').addClass('inputWithText');
        }
      });
   });

Just append body i.e $('body .inputWithLabel') in your each loop.

like image 159
Rohan Kulkarni Avatar answered Nov 17 '22 06:11

Rohan Kulkarni