Any idea why the following dropdownlist won’t validate with required field as type int (the “Title” field below)?
[Required] // This works!
[Display(Name = "Name")]
public string Name { get; set; }
[Required] // This doesn't work
[Display(Name = "Title")]
public int TitleId { get; set; }
<div class="editor-label">
@Html.LabelFor(model => model.Name, "Name")
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name, "This can't be blank!")
</div>
<div class="editor-label">
@Html.LabelFor(model => model.TitleId, "Title")
</div>
<div class="editor-field">
@Html.DropDownListFor(model => model.TitleId, (SelectList)ViewBag.TitleId, String.Empty)
@Html.ValidationMessageFor(model => model.TitleId)
</div>

According to this work item, client-side validation breaks when the SelectList in the ViewBag uses the same name as the field in question. (i.e. both are
TitleIdin your case.)Try this:
with your SelectList renamed to
TitleIdListaccordingly.