Welcome to WebmasterWorld Guest from 54.204.162.36

Forum Moderators: incrediBILL

autocomplete="off"

Does not validate html

   
5:43 pm on Jun 15, 2005 (gmt 0)

10+ Year Member



Since autocomplete="off" invalidates html, is there another better way I can use it. I want it to inactivate ALL inputs like they do in <form>. How do I get around to it?
6:01 pm on Jun 15, 2005 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member



autocomplete="off"
is an unrecognized attribute according to the HTML specifications. It was originally created by Microsoft (one of their better ideas) and has been adopted by all major modern browsers other than Opera (they have a strange stance on this one).

The validation error is competely harmless in that conformant HTML parsers are supposed to ignore unknown attributes. I have no hesitation in using this attribute where required, and I wouldn't reduce user experience to achieve validity.

6:12 pm on Jun 15, 2005 (gmt 0)

10+ Year Member



Found while googling for it:

<script type="text/javascript">
function init() {
if (!document.getElementById) return false;
var f = document.getElementById('auto_off');
var u = f.elements[0];
f.setAttribute("autocomplete", "off");
u.focus();
}
</script>
<body onload='init()'>
<form id="auto_off">

Now validates html.

[edited by: tedster at 8:34 pm (utc) on June 15, 2005]
[edit reason] remove link [/edit]

6:35 pm on Jun 15, 2005 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member



f.setAttribute("autocomplete", "off");

The thing is you're actually just using a Javascript function to hide the fact that you're using an unrecognized attribute. It's a "fake" validation because you're using the DOM to add the attribute by stealth in a way the validator doesn't understand. You don't really gain anything, but you make the presence of the attribute dependent on Javascript being enabled and are replacing one small attribute with a dozen lines of script.

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month