The validation message for a field is being output twice for a TextBoxFor, TextBox, PasswordFor or Password control when the SetValidationMessageInline is set.
ModelState.AddModelError("Text", "The text is bad");
The output is
<div class=" has-error form-group">
<label class="control-label col-lg-2" for="Text">Text<span class="required" style="visibility:hidden;">*</span> </label>
<div class="col-lg-10"><input class="input-validation-error form-control" id="Text" name="Text" type="text" value="">
<span class="field-validation-error" data-valmsg-for="Text" data-valmsg-replace="true">The text is bad</span>
</div>
<span class=" help-block"><span class="field-validation-error" data-valmsg-for="Text" data-valmsg-replace="true">The text is bad</span></span>
</div>
I would not have expected to see the span.field-validation-error written inside the div.col-lg-10. Only one validation message is output if inline is not used.
The validation message for a field is being output twice for a
TextBoxFor
,TextBox
,PasswordFor
orPassword
control when theSetValidationMessageInline
is set.Take the following example on version 3.14.6:
The output is
I would not have expected to see the
span.field-validation-error
written inside thediv.col-lg-10
. Only one validation message is output if inline is not used.