如何使用MVC所需的HTML5

时间:2014-09-23 19:58:32

标签: asp.net-mvc html5

我的申请是MVC。

在HTML5中,我们可以使用required

<input type="text" name="username" required>

如何告诉MVC使用必需属性作为我的代码

@Html.TextBoxFor(a => a.Name, new { @class = "textBox", placeholder = "Required", required })

没有做到!

1 个答案:

答案 0 :(得分:0)

我猜你的占位符也不起作用,

尝试替换

@Html.TextBoxFor(a => a.Name, new { @class = "textBox", placeholder = "Required", required })

使用

@Html.TextBoxFor(a => a.Name, new { @class = "textBox", @placeholder = "Required", @required  = "required"})