I have a login form where, if the fields are filled with data, a javascript (jquery) adds a class to them.
The problem appears when the fields are auto-filled by Google Chrome if you save the access credentials. Is there a way to check if Chrome (or any other browser) has autofill the field and launch the JS function so the correct classes are applied?
EDIT giving any input from the keyboard/mouse, the script is fired and it works correctly. Unfortunately, I want it working without user input but o page load.
Example below
main.html
<input type="password" class="input100" name="password">
main.js
$('.input100').each(function(){
$(this).on('blur', function(){
if($(this).val().trim() != "") {
$(this).addClass('has-val');
}
else {
$(this).removeClass('has-val');
}
})
})