I have edit bar for gender and i want to valid it (Male or Female), there is my model class:
public int CustomerID { get; set; }
public int BranchID { get; set; }
public string FirstName { get; set; }
public string SirName { get; set; }
public int Age { get; set; }
public string Gender { get; set; }
and here is my view part i want to valid:
<div class="editor-label">
@Html.LabelFor(model => model.Gender)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Gender)
@Html.ValidationMessageFor(model => model.Gender)
</div>
Gendershould beRadioButton Group, for that useEnum. And then make itRequired, thats it.