Jack Nicholson Jack Nicholson - 5 months ago 9
CSS Question

Explicitly state input box is not for usernames/logins

Chrome is autofilling a box on a form on a website with the login username and when you submit the form it asks to save the login.

How can I force Chrome to leave the input field alone?

It's trying to be too smart for its own good.

<input type="text" placeholder="(Optional)" name="auth_code" />


It auto-fills with the login username:

enter image description here

EDIT:
I tried adding

autocomplete="off"


But the field still auto-fills with the login username on page load.

Another note:

I already have

value=""


But Chrome still auto-fills it.

Answer
$(document).ready(function() {

    $('#TheInput').val('');

    setTimeout(function () {

       $('#TheInput').val('');

    }, 100);
});

This code runs twice, just in case there's a browser-specific issue. It will definitely clear the input and requires jQuery, which may or may not be an issue for you. I also added an ID to reference the input element.

<input id="TheInput" type="text" placeholder="(Optional)" name="auth_code" />