0
Я пытаюсь проверить правильность приведенного ниже переключателя, тогда необходимо выбрать хотя бы один из этих флажков.Проверка флажка только при выборе этого переключателя
@using (Html.BeginForm("Print","Home",FormMethod.Post, new{ @class="form", role ="form")
{
@Html.AntiForgeryToken();
<div class="col-md-12">
<div class="alert alert-info">
If you are multiracial, please complete this item by indicating the ethnic/racial group you identify with most or the ethnic/racial group to which you are usually regarded in the community as belonging.
</div>
</div>
<div class="col-md-9">
<div class="form-group">
@Html.LabelFor(model => model.IsMultiracial, "Are you Multiracial?", new { @class = "control-label" })
@Html.RadioButtonFor(model => model.IsMultiracial, "false", new { onclick = "showRacial(this.value)" }) No
@Html.RadioButtonFor(model => model.IsMultiracial, "true", new { onclick = "showRacial(this.value)" }) Yes
</div>
</div>
</div>
<div class="row">
<div id="multiracial" style="display: none;">
<div class="col-md-9">
<div class="form-group">
@for (int i = 0; i < Model.ParentRacialGroups.Count(); i++)
{
<input type="hidden" name="ParentRacialGroups.Index" value="@i" />
<input type="checkbox" id="ParentRacialGroup" name="ParentRacialGroups[@i].ID" value="@Model.ParentRacialGroups[i].ID" checked="@Model.ParentRacialGroups[i].isChecked" data-size="xs" />
<label class="cbx-label small" for="check-2g">@Model.ParentRacialGroups[i].name</label>
<br />
}
</div>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-offset-2 col-md-4">
<div class="form-group">
<input type="submit" class="btn btn-default" value="Print" />
</div>
</div>
</div>
}
просто передайте объект 'this' в методе showRacial и внутри метода проверьте if (this.checked == true) then this.value – Sushil
Как будет проверяться форма? – Steven
Что вы используете для проверки? – Sushil