编辑:
<div class="editor-item">
<label for="Location">Location</label><input class="input-validation-error ui-autocomplete-input" data-jqui-acomp-delay="400" data-jqui-acomp-hiddenvalue="LocationId" data-jqui-acomp-minlength="3" data-jqui-acomp-source="/Loc/Search" data-jqui-type="autocomplete" id="Location" name="Location" type="text" value="123 wrong address" autocomplete="off">
<span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span><span class="field-validation-error" data-valmsg-for="Location" data-valmsg-replace="true">Location not found</span></div>
当用户提交按钮时,我正在检查该位置是否存在,如果不存在,那么我将添加 ModelState.AddmodelError
ModelState.AddModelError((LocationViewModel m) => m.Location, "Location not found");
我的问题是:当用户点击复选框Create Location
时,我怎样才能让错误消失?
<span id="CreateNLocation" >
@Html.LabelFor(model => model.CreateLocation, "Create Location")
@Html.CheckBoxFor(model => model.CreateLocation)
</span>
在运行时渲染:
<span id="CreateNLocation" style="">
<label for="CreateLocation">Create Location</label>
<input data-val="true" data-val-required="The Create new Location field is required." id="CreateLocation" name="CreateLocation" type="checkbox" value="true">