homepage Welcome to WebmasterWorld Guest from 54.204.249.184
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
autocomplete="off"
Does not validate html
LinuxGold




msg:568327
 5:43 pm on Jun 15, 2005 (gmt 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?

 

encyclo




msg:568328
 6:01 pm on Jun 15, 2005 (gmt 0)

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.

LinuxGold




msg:568329
 6:12 pm on Jun 15, 2005 (gmt 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]

encyclo




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved