Twitter bootstrap sitefinity验证数据视图
我构建此MVC表单时没有使用sitefinity表单控件。我想将validate添加到First Name文本框中。在模型中,我对视图使用的视图模型中的属性具有[Required]属性。我只得到红色文本Twitter bootstrap sitefinity验证数据视图,twitter-bootstrap,bootstrap-4,telerik,sitefinity,Twitter Bootstrap,Bootstrap 4,Telerik,Sitefinity,我构建此MVC表单时没有使用sitefinity表单控件。我想将validate添加到First Name文本框中。在模型中,我对视图使用的视图模型中的属性具有[Required]属性。我只得到红色文本FirstName字段是必需的。但我希望文本框和标签也是红色的。有没有其他类我需要使用的文本框或任何与引导 看法 看法 你可以达到预期的效果, 你需要包装你的代码 @Html.TextBoxFor(x => x.FirstName, new { @class = "form-con
FirstName字段是必需的。
但我希望文本框和标签也是红色的。有没有其他类我需要使用的文本框或任何与引导
看法
看法
你可以达到预期的效果, 你需要包装你的代码
@Html.TextBoxFor(x => x.FirstName, new { @class = "form-control", @id = "txtFirstName" })
@Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" })
在类为“error exist”或您喜欢的任何名称的div中
此外,还需要添加一些次要Css,如下所述:
.error-exist label
{
color:red !important;
}
.error-exist input[type="text"]
{
border:1px solid red !important;
}
通常,要在页面上初始化jquery验证插件,您需要执行以下操作
<script>
$(function() {
$("form").validate();
})
</script>
$(函数(){
$(“表单”).validate();
})
你的意思是与col-sm-6 div不同吗?我仍然只得到@Html.validationmessage,而没有红色文本。我可以将文本框轮廓设置为红色吗?
@Html.TextBoxFor(x => x.FirstName, new { @class = "form-control", @id = "txtFirstName" })
@Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" })
.error-exist label
{
color:red !important;
}
.error-exist input[type="text"]
{
border:1px solid red !important;
}
<script>
$(function() {
$("form").validate();
})
</script>