Asp.net mvc asp.net MVC3不引人注目的验证会导致IE8浏览器挂起
我使用不引人注目的验证来验证表单。它可以在大多数浏览器中工作——IE7、兼容模式下的IE8、FF和Chrome。然而,在IE8独立模式下,它触发验证并显示消息。当我转到该字段并在其中重新键入值时,浏览器在第一次按键后挂起。错误消息不会自动消失。这适用于所有表单和所有类型的验证属性(必需、远程或正则表达式) 我使用的是jQuery1.6.4和jQueryValidation 1.8.1 谁能帮帮我吗 视图模型Asp.net mvc asp.net MVC3不引人注目的验证会导致IE8浏览器挂起,asp.net-mvc,internet-explorer-8,unobtrusive-validation,Asp.net Mvc,Internet Explorer 8,Unobtrusive Validation,我使用不引人注目的验证来验证表单。它可以在大多数浏览器中工作——IE7、兼容模式下的IE8、FF和Chrome。然而,在IE8独立模式下,它触发验证并显示消息。当我转到该字段并在其中重新键入值时,浏览器在第一次按键后挂起。错误消息不会自动消失。这适用于所有表单和所有类型的验证属性(必需、远程或正则表达式) 我使用的是jQuery1.6.4和jQueryValidation 1.8.1 谁能帮帮我吗 视图模型 试着使用最新版本的你能把你的代码剪下来,并在一个你可以粘贴到这里查看的示例中证明错误吗?
试着使用最新版本的你能把你的代码剪下来,并在一个你可以粘贴到这里查看的示例中证明错误吗?我已经添加了源代码。谢谢。嘿@Madhu-你有没有找到解决这个问题的方法。我对IE8也有类似的问题。谢谢您的及时回复。不幸的是,这并不能解决这个问题。在另一个项目中,为验证消息生成的html是。但是,在这个项目中,html是生成的。i、 e.用于而不是htmlFor。我想,这就是原因。我使用IE8中的开发工具获取了这个html。但是,我如何纠正这一点?
namespace xxxxx.ViewModel
{
/// <summary>
/// SubjectVM
/// </summary>
public class SubjectVM
{
#region Public Properties
#region SubjectID
/// <summary>
/// SubjectID
/// </summary>
public int SubjectID { get; set; }
#endregion
#region Name
/// <summary>
/// Name
/// </summary>
[Display(Name = "Subject Name")]
[Required(ErrorMessage = "Please enter Name of the subject")]
[Remote("IsSubjectNameUnique", "Subject", AdditionalFields = "SubjectID",
ErrorMessage = "The Name given for Subject is already used for another Subject. Please give a different Name.")]
[UIHint("SingleLineText")]
[HtmlProperties(MaxLength = 50, Size = 30)]
public string Name { get; set; }
#endregion
#region Description
/// <summary>
/// Description
/// </summary>
[Display(Name = "Description")]
[StringLength(500)]
[UIHint("MultiLineText")]
[HtmlProperties(Rows = 4, Cols = 25, MaxLength = 500)]
public string Description { get; set; }
#endregion
#region Code
/// <summary>
/// Code
/// </summary>
[Display(Name = "Subject Code")]
[Required(ErrorMessage = "Please enter subject code")]
[Remote("IsSubjectCodeUnique", "Subject", AdditionalFields = "SubjectID",
ErrorMessage = "The Subject Code given is already used for another Subject. Please give a different Subject Code.")]
[HtmlProperties(MaxLength = 10, Size = 30)]
[UIHint("SingleLineText")]
public string Code { get; set; }
#endregion
}
}
#region Create
/// <summary>
/// Create
/// </summary>
/// <returns></returns>
public override ActionResult Create()
{
SubjectVM blankObject = new SubjectVM();
return View("Subject", blankObject);
}
#endregion
@model xxxx.SubjectVM
@{
ViewBag.Title = "Subject";
}
<h2>Subject</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Subject</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Description)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Code)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Code)
@Html.ValidationMessageFor(model => model.Code)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@model string
@using xxxx.MVCLibrary;
@{
HtmlPropertiesAttribute htmlAttributes = null;
if (ViewData.ModelMetadata.AdditionalValues.ContainsKey("HtmlAttributes"))
{
htmlAttributes = (HtmlPropertiesAttribute)ViewData.ModelMetadata.AdditionalValues["HtmlAttributes"];
}
@Html.TextBoxFor(Model => Model, htmlAttributes.HtmlAttributes());
}