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?
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;
}
简单地用div包围它应该可以解决问题
<div>@Html.ValidationMessageFor(m => m.Email)</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.