How to add required field validation on client side with custom message for Radio Button in ASP.Net MVC ?
<div class="form-group">
<div class="col-sm-4 control-label">
<label class="hthin" asp-for="IsGuidance"></label>
<label class="hthin">Coach: @Model.GuideName</label>
</div>
<div class="col-sm-3 checkbox-inline">
@Html.RadioButtonFor(model => model.IsGuidance, 1, new { @Id = "IsGuidanceYes" })
<label class="hthin" for="IsGuidanceYes">Yes</label>
@Html.RadioButtonFor(model => model.IsGuidance, 0, new { @Id = "IsGuidanceNo" })
<label class="hthin" for="IsGuidanceNo">No</label>
<span asp-validation-for="IsGuidance" class="text-danger"></span>
</div>
</div>
I wrote a Jquery file :
$('input[name="IsGuidance"]').rules("add",
{
required: true,
messages: {
required: "Please select Yes or No"
}
});
Though, this is not validating (or) validation message is not showing on the UI.