Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twitter bootstrap sitefinity验证数据视图_Twitter Bootstrap_Bootstrap 4_Telerik_Sitefinity - Fatal编程技术网

Twitter bootstrap sitefinity验证数据视图

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

我构建此MVC表单时没有使用sitefinity表单控件。我想将validate添加到First Name文本框中。在模型中,我对视图使用的视图模型中的属性具有[Required]属性。我只得到红色文本
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>