我想验证文本框,文本框是列表类型,以便如何使用JavaScript进行验证?
我需要以下验证:
文本框不应为空,不能重复
以下是我的代码
@model List
@using (Html.BeginForm("CreateCategory", "CategoryAndSubCategory", FormMethod.Post, new { enctype = "multipart/form-data", @id = "category" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.Label("Category Name", htmlAttributes: new { @class = "control-label col-md-2 required" })
@Html.EditorFor(a => a[j].Category, new { @class = "form-control", @placeholder = "Enter Category Name", @style = "text-transform: capitalize" })
@Html.ValidationMessageFor(a => a[j].Category, "", new { @class = "text-danger" })
}