加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 00:24:35 所属栏目:asp.Net 来源:网络整理
导读:我在MVC中有以下视图,并且会收到警告消息:验证(HTML5):元素“图例”发生的次数太少 @model Berwin.Models.ViewModels.UserViewModel@{ViewBag.Title = "Press";}h2Press Area/h2@using (Html.BeginForm("Register","PressController",FormMethod.Post)){f
我在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等)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读