问题描述
我正在尝试清理我的xhtml验证 - 我正在通过W3C验证器运行我的页面。出于某些令人费解的原因,它没有使用autocomplete =off属性传递输入字段:
I'm trying to cleanup my xhtml validation -- I'm running my pages through the W3C validator. For some puzzling reason it's not passing on input fields with the autocomplete="off" attribute:
<input name="kwsearch" id="sli_search_1" type="text" autocomplete="off" onfocus="if(this.defaultValue==this.value) this.value='';"
onblur="if(this.value=='')this.value=this.defaultValue;" class="searchbox" value="Search" />
我正在使用此doctype:
I'm using this doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
这是验证错误:
第410行,第81列:没有属性自动完成
Line 410, Column 81: there is no attribute "autocomplete"
... li_search_1type =textautocomplete =offonfocus =if(this.defaultValue == thi ...
…li_search_1" type="text" autocomplete="off" onfocus="if(this.defaultValue==thi…
我认为这对W3C来说没问题 - 但是,也许它还处于提交阶段?
I thought this was okay with the W3C -- but, maybe it's still in "submission" phase? http://www.w3.org/Submission/web-forms2/#autocomplete
思考?
推荐答案
Web表单规范与HTML 4无关/ XHTML。遗憾的是, autocomplete
将无法通过验证。
The Web forms specification has nothing to do with HTML 4 / XHTML. Sadly, autocomplete
will not pass validation.
我认为实现有效HTML 4的唯一方法是关闭自动完成功能的XHTML是使用JavaScript在页面加载时添加属性。我知道这很糟糕 - 但我认为这是唯一的方法。
I think the only way to achieve valid HTML 4 /XHTML with autocomplete turned off is adding the attribute on page load using JavaScript. Sucks, I know - but I think it's the only way.
这篇关于autocomplete属性没有通过XHTML 1.0 Transitional验证,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!