我正在尝试有条件地验证 MVC.NET Core 中的字段。我有两个单选按钮。如果我选择是(对于所有权),我想在下面填写一个必填字段(活动下拉菜单)
但是,无论我如何努力,要验证的值始终来自 Activity 字段,而不是来自 Ownership 字段(“N\A”而不是“Yes”)
有人可以告诉我我做错了什么吗
视图 (chtml)
<div class=" form-group">
<div class="bisformdynamiclabel"></div>
<br />
@Html.RadioButtonFor(model => model.BIS232Request.JSONData.OwnershipActivity.Ownership, "Yes", new { id = "OwnershipAnswer_true", onclick = "displayOwnershipFieldsRow(true)" })
<label for="OwnershipAnswer_true">Yes</label>
@Html.RadioButtonFor(model => model.BIS232Request.JSONData.OwnershipActivity.Ownership, "No", new { id = "OwnershipAnswer_false", onclick = "displayOwnershipFieldsRow(false)" })
<label for="OwnershipAnswer_false">No</label>
<span class="alert-danger">
@Html.ValidationMessage("OwnershipAnswer")
</span>
</div>
<div class="row ownershipfieldsrow">
<div class="col-xs-12 col-md-12">
<div class=" form-group">
<div class="bisformdynamiclabel"></div>
<br />
<input style="display:none" class="form-control" type="text" asp-for="BIS232Request.JSONData.OwnershipActivity.Activity" />
<select class="form-control ownershipactivityselect" onchange="$('#BIS232Request_JSONData_OwnershipActivity_Activity').val($(this).val()); ">
<option value="N/A">Please Select</option>
<option value="Manufacturer">Manufacturer</option>
<option value="Distributor">Distributor</option>
<option value="Exporter">Exporter</option>
<option value="Importer">Importer</option>
<option value="Other">Other</option>
</select>
<span asp-validation-for="BIS232Request.JSONData.OwnershipActivity.Activity" class="alert-danger"></span>
<span class="alert-danger">
@Html.ValidationMessage("OwnershipAnswerActivity")
</span>
</div>
</div>
慕妹3146593
拉丁的传说
侃侃尔雅
相关分类