Chrome warning "[DOM] Password forms should have (optionally hidden) username fields for accessibility" in console even with hidden username field Chrome warning "[DOM] Password forms should have (optionally hidden) username fields for accessibility" in console even with hidden username field google-chrome google-chrome

Chrome warning "[DOM] Password forms should have (optionally hidden) username fields for accessibility" in console even with hidden username field


I had the same problem. After some digging, I found that it needs to be an input element with the type text. By "optionally hidden" they mean that you may hide it with CSS.

If you just add an input with the name email or username chrome gives you another warning saying that input elements should have autocomplete attributes. So this is what I came up with to fix these errors:

<input type="text" name="email" value="..." autocomplete="username email" style="display: none;">.

You will need to manually render the actual username or email into the elements value attribute.

Also, keep in mind that inline styles are not a very good practice.


Use the hidden attribute instead of type="hidden"

<input hidden type="text" autocomplete="username" value="{{...}}">


I had this same situation.Everything seemed be ok but I still got this verbose.

On my case helped me a relocate this userName input from end of form to begin of that.

It was my code before my changes:

<form id="changePass">    <div class='modal-dialog'>       <input type="password" class="form-control" id = "changePasswordOldPassword" autocomplete="current-password"/>       <input type="password" class="form-control" id = "changePasswordNewPassword" autocomplete="new-password"/>       <input type="password" class="form-control" id = "changePasswordNewPassword2" autocomplete="new-password"/>       <div class="modal-footer">          <button type="button" id="change-password-ok-button">Ok</button>          <button type ="button" data-dismiss="modal">Close</button>       </div>   </div>   <input id="userName" name="username" autocomplete="username" value=""></form>

And this is current code:

<form id="changePass">   <input id="userName" name="username" autocomplete="username" value="">   <div class='modal-dialog'>       <input type="password" class="form-control" id = "changePasswordOldPassword" autocomplete="current-password"/>       <input type="password" class="form-control" id = "changePasswordNewPassword" autocomplete="new-password"/>       <input type="password" class="form-control" id = "changePasswordNewPassword2" autocomplete="new-password"/>       <div class="modal-footer">          <button type="button" id="change-password-ok-button">Ok</button>          <button type ="button" data-dismiss="modal">Close</button>       </div>   </div></form>