Reputation: 68800
I have a validation message for my model:
<td colspan="2">
<div class="rereg-input">
@Html.TranslatedTextBoxFor(m => m.Email)
@Html.ValidationMessageFor(m => m.Email)
</div>
</td>
When the user forgets, the text nicely displays a * beside the field:
But when they enter a bad email, the message gets put on the end. How can I get it under?
Upvotes: 7
Views: 6256
Reputation: 50229
You need to rearrange/fix the CSS/HTML structure.
<td colspan="2">
<div class="rereg-input">
@Html.TranslatedTextBoxFor(m => m.Email)
<div>
@Html.ValidationMessageFor(m => m.Email)
</div>
</div>
</td>
You may be better off modifying whatever CSS class MVC puts on the validation message element and set display:block;
.
.validation-message {
/* ... */
display:block;
}
Upvotes: 8
Reputation: 729
Simply surrounding it with a div should do the trick
<div>@Html.ValidationMessageFor(m => m.Email)</div>
Upvotes: 6