Among other text and visual aids on a form submission, post-validation, I\'m coloring my input boxes red to signify the interactive area needing attention.
On Chrome
for today's versions, This works too if placed in one of the two login inputs. Also fix the version 40+ and late Firefox issue.
<input readonly="readonly" onfocus="this.removeAttribute('readonly');" />
To remove the border for all fields you can use the following:
*:focus { outline:none; }
To remove the border for select fields just apply this class to the input fields you want:
.nohighlight:focus { outline:none; }
You can of course change the border as you desire as well:
.changeborder:focus { outline:Blue Solid 4px; }
(From Bill Beckelman: Override Chrome's Automatic Border Around Active Fields Using CSS)
This works. Best of all, you can use rgba values (the box-shadow inset hack doesn't work with rgba). This is a slight tweak of @Benjamin's answer. I am using $(document).ready() instead of $(window).load(). It seems to work better for me - now there's much less FOUC. I don't believe there are and disadvantages to using $(document).ready().
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
$(document).ready(function() {
$('input:-webkit-autofill').each(function(){
var text = $(this).val();
var name = $(this).attr('name');
$(this).after(this.outerHTML).remove();
$('input[name=' + name + ']').val(text);
});
});
};
By using a bit of jQuery you can remove Chrome's styling while keeping the autocomplete functionality intact. I wrote a short post about it here: http://www.benjaminmiles.com/2010/11/22/fixing-google-chromes-yellow-autocomplete-styles-with-jquery/
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
$(window).load(function(){
$('input:-webkit-autofill').each(function(){
var text = $(this).val();
var name = $(this).attr('name');
$(this).after(this.outerHTML).remove();
$('input[name=' + name + ']').val(text);
});
});}
Yes, it would be a major headache, which in my opinion isnt worth the return. Maybe you could tweak your UI strategy a bit, and instead of coloring the box red, you could color the borders red, or put a small red tape beside it (like the gmails "Loading" tape) which fades away when the box is in focus.
I know in Firefox you can use the attribute autocomplete="off" to disable the autocomplete functionality. If this works in Chrome (haven't tested), you could set this attribute when an error is encountered.
This can be used for both a single element
<input type="text" name="name" autocomplete="off">
...as well as for an entire form
<form autocomplete="off" ...>