I have a radio button that is displaying a boolean field. When I submit the form data without checking the Radio button, it does not save as the field is required but it does not show a validation message. All the textboxes show the validation message, only the Radio button does not show validation message.
I have added:
[Required]to the field in the view model@Html.ValidationMessageFor(m => m.isCurrent)in the view
However, it still does not show the error message.
Has anyone encountered a similar problem?
VIEWMODEL
[Required]
public bool? isCurrent { get; set; }
VIEW
<label type='checkbox'>
Is this bus still a part of your fleet?
<div>
@Html.RadioButtonFor(m => m.isCurrent, true, new {id = "Yes"}) @Html.Label("Yes", "Yes")
@Html.RadioButtonFor(m => m.isCurrent, false, new {id = "No"}) @Html.Label("No", "No")
@Html.ValidationMessageFor(m => m.isCurrent)
</div>
</label>