我的申请是MVC。
在HTML5中,我们可以使用required
如
<input type="text" name="username" required>
如何告诉MVC使用必需属性作为我的代码
@Html.TextBoxFor(a => a.Name, new { @class = "textBox", placeholder = "Required", required })
没有做到!
答案 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"})