w3c 验证问题
我很困惑,w3c 验证服务似乎在说 asp.net 无法合法地在页面上的表单标记内呈现隐藏字段,看看这个...
http://validator.w3.org/check?uri=http%3a%2f%2fmotcombegarage%2eco%2euk%2f
据我所知,它似乎在说以下内容代码示例是无效标记 WTF !!!
<html>
<head> ... header stuff ... </head>
<body>
<form method="post" action="" id="ctl01">
<div class="aspNetHidden">
<input type="hidden" name="ctl09_HiddenField" id="ctl09_HiddenField" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NzEyODQ1M2RkJPtW5VtaL7LPuSxnn1JM1yVnOeGAovb8b4b3KShHy4M=" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwKt17cxAr+s9MgFAqjXzJsHz7KyzLpZjYtTK89blY7GgKAElK/5syvVNn4h7rVehcQ=" />
</div>
... other code ...
</form>
</body>
</html>
如果代码实际上无效,这会给我带来两个问题:
- 此代码是由 .net 框架生成的,用于处理回发,因此编辑它可能是一个问题,
- 我不知道表单字段的有效上下文应该是什么(lolz)
这是一个错误还是我做错了什么???
编辑: 正如下面 Peter O 所指出的,我在标记中添加了缺少的 div 标签...将其与验证器使用的标记进行比较表明,该 div 虽然存在于标记中,但显然不值得验证...所以这有点改变问题...为什么它忽略那个 div ? ...
似乎有点奇怪,你不能直接将输入标签放入表单标签中...当然这就是表单标签的要点,包含输入标签?
im confused, the w3c validation service seems to be saying that asp.net cannot legally render a hidden field inside a form tag on the page, have a look at this ...
http://validator.w3.org/check?uri=http%3a%2f%2fmotcombegarage%2eco%2euk%2f
from what i can tell it seems to be saying that the following code sample is invalid markup WTF !!!
<html>
<head> ... header stuff ... </head>
<body>
<form method="post" action="" id="ctl01">
<div class="aspNetHidden">
<input type="hidden" name="ctl09_HiddenField" id="ctl09_HiddenField" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NzEyODQ1M2RkJPtW5VtaL7LPuSxnn1JM1yVnOeGAovb8b4b3KShHy4M=" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwKt17cxAr+s9MgFAqjXzJsHz7KyzLpZjYtTK89blY7GgKAElK/5syvVNn4h7rVehcQ=" />
</div>
... other code ...
</form>
</body>
</html>
This presents 2 problems for me if the code is in fact invalid:
- This code is generated by the .net framework for handling postbacks so editing it could be a problem
- i have no idea what the valid context for a form field should be (lolz)
Is this a bug or have i done something wrong ???
EDIT:
As pointed out by Peter O below I added the missing div tag in my markup ... comparing this to the markup that the validator uses shows that this div whilst present in the markup is apparently not worth validating ... so that kinda changes the question to ... why is it ignoring that div ? ...
Seems a bit odd that you can't put an input tag inside a form tag directly though ... surely thats the point of a form tag, to contain input tags ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我似乎摆脱该消息的唯一方法是按照主页上的代码为第一个隐藏输入分配一个值
在所有情况下,这很可能是一个错误。
The only way I've seemed to get rid of the message, following the code on your homepage, is to assign a value to the first hidden input
In all liklihood, this is most likely a bug.
INPUT 元素应放置在 DIV 元素内,如下所示:
The INPUT elements should be placed within a DIV element, like this: