Welcome to WebmasterWorld Guest from 54.160.198.60

Forum Moderators: incrediBILL

Message Too Old, No Replies

autocomplete="off"

Does not validate html

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

Junior Member

10+ Year Member

joined:Aug 21, 2003
posts:74
votes: 0


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 June 15, 2005 (gmt 0)

Senior Member from CA 

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

joined:Aug 31, 2003
posts:9068
votes: 4


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 June 15, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 21, 2003
posts:74
votes: 0


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 June 15, 2005 (gmt 0)

Senior Member from CA 

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

joined:Aug 31, 2003
posts:9068
votes: 4


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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members