微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

asp.net-mvc – HTML5元素的“传说”太少了

我在MVC中有以下视图,并且会收到警告消息:验证(HTML5):元素“图例”发生的次数太少
@model Berwin.Models.viewmodels.Userviewmodel

@{
ViewBag.Title = "Press";
}

<h2>Press Area</h2>

@using (Html.BeginForm("Register","PressController",FormMethod.Post))
{
<fieldset>
    @Html.TextBoxFor(model => model.FullName)
</fieldset>

<fieldset>
    @Html.TextBoxFor(model => model.Company)
</fieldset>

<fieldset>
    @Html.TextBoxFor(model => model.EmailAddress)
</fieldset>

<fieldset>
    @Html.CheckBoxFor(model => model.JoinMailingList)
</fieldset>
}

想知道为什么我得到这个警告,我需要做什么来解决这个问题。

解决方法

根据HTML 5规范,< legend>标记不是< fieldset>中的必需元素。

The legend element represents a caption for the rest of the contents
of the legend element’s parent fieldset element,if any.

文件http://www.w3.org/TR/html5/forms.html#the-legend-element

在您的情况下,它只是由Visual Studio插件提供的警告。它不是必需的,并且可能有一种方法来抑制“工具” – “选项” – “文本编辑器” – “HTML – 验证”下的警告。在这里,您还可以切换验证的目标(HTML 5,XHTML 1等)

原文地址:https://www.jb51.cc/aspnet/252190.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐