DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
224 stars 79 forks source link

Validation messages are being output twice #371

Closed liamdavies closed 9 years ago

liamdavies commented 9 years ago

The validation message for a field is being output twice for a TextBoxFor, TextBox, PasswordFor or Password control when the SetValidationMessageInline is set.

Take the following example on version 3.14.6:

@{
    Html.Bootstrap().Globals().SetValidationMessageInline();
}
@using (var f = Html.Bootstrap().Begin(new Form().Type(FormType.Horizontal)))
{
    @f.FormGroup().TextBoxFor(m => m.Text)
}
            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.

liamdavies commented 9 years ago

Hi Dmitry Do you have any update on getting this fixed? Thanks

DmitryEfimenko commented 9 years ago

This is fixed. Please get latest.