HTML TextBoxFor与验证

时间:2019-05-22 13:14:25

标签: html validation

我有以下内容,如果未填充TextBoxFor,则会导致红色验证消息出现。效果很好,但我希望在TextBoxFor placholder所在的位置出现验证消息。

有没有办法在html内做到这一点?

@Html.TextBoxFor(x => Model.Username, new { type = "email", id = "emailEntry", placeholder = "Email address..", @class = "form-control" })

@Html.ValidationMessageFor(x => Model.Username, "Email address is required", new { @class = "text-danger" })

0 个答案:

没有答案