Required Field Validator funktioniert nicht für die von JQuery ausgewählte Dropdown-Liste
Ich verwende JQuery Choosen für meine DropDownList, aber der erforderliche Validator für diese Dropdown-Liste funktioniert nicht. Das Folgen ist mein Code. Bitte führen Sie, wo ich falsch liege.
Ausgewähltes Plugin im Formular enthalten
$(".chosen-select").chosen();
DropDownList code
<li>
@Html.LabelFor(m => m.DepartmentId)
@Html.DropDownListFor(x => x.DepartmentId, (ViewBag.DepartmentsList) as IEnumerable<SelectListItem>, "-- Select an Option --",new { @class = "chosen-select", @style = "width:312px; height:31px;" })
@Html.ValidationMessageFor(m => m.DepartmentId)
</li>
Und Model für die DropDownList
[Required(ErrorMessage = "*")]
[Display(Name = "Department Name")]
public int DepartmentId { get; set; }