我有以下代码,它在所有浏览器中都能正常工作,并在用户尝试提交表单而不输入字段名称时显示错误消息。
<div class="row medium left">
@Html.TextBox("FirstName", Model.FirstName, new { @class = "field blink medium required", @title = "First Name*" })
<div class="error-msg">
@Html.ValidationMessageFor(m => m.FirstName)
</div>
</div>
<div class="row medium left last">
@Html.TextBox("LastName", Model.LastName, new { @class = "field blink medium required", @title = "Last Name*" })
<div class="error-msg">
@Html.ValidationMessageFor(m => m.LastName)
</div>
</div>
验证消息适用于除 IE 之外的所有浏览器。有什么问题,我可能忽略了什么错误?
在 IE 中渲染的 HTML:
<input name="FirstName" title="First Name*" class="field blink medium required error" id="FirstName" type="text" value="First Name*" data-val-required="The First Name field is required." data-val-length-min="3" data-val-length-max="50" data-val-length="Minimum of 3 characters." data-val="true" AUTOCOMPLETE="OFF">
<div class="error-msg">
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg- for="FirstName"></span></div>