私は控えめな検証を使用してフォームを検証しています。ほとんどのブラウザ(IE7、IE8互換モード、FF、Chrome)で動作します。しかし、IE8のスタンドアロンモードでは、検証を実行し、メッセージが表示されます。フィールドに移動して値を再入力すると、の最初のキーを押した後、ブラウザはをハングします。エラーメッセージは自動的に消えません。これは、すべてのフォームおよびすべてのタイプの検証属性(必須、リモートまたは正規表現)で発生します。asp.net MVC3の邪魔にならない検証によりIE8ブラウザがハングアップする
私はjquery 1.6.4とjquery validation 1.8.1を使用しています。
誰でもお手伝いできますか?
ビューモデル
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>
UIのヒント - SingleLineText
@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());
}
jquery validation 1.9の最新バージョンを使用して、あなたが見にここに貼り付けることができますサンプルでエラーを証明するには? –
私はソースコードを追加しました。ありがとう。 – Madhu
こんにちは@Madhu - あなたはこの問題を克服する方法を練習しましたか?私はie8と同様の問題があります – Rob