1. Property should be nullable in model.
2. script code should be in separate js file
3. Add Following code at top of js file
$.validator.setDefaults({ ignore: ":hidden:not(select)" });
$.validator.unobtrusive.parse($("#form_ConflictOfInterest"));
[Required(ErrorMessage = "This field is required")]
public int? EmpID { get; set; }
@Html.DropDownListFor(model => model.EmpId, Model.EmpList, "Select", new { @id = "ddlEmpid", @class = "ddlEmpid", data_placeholder = "Select", @style = "width:100%;" })
@Html.ValidationMessageFor(k=>k.EmpId)
No comments:
Post a Comment