我正在使用MVC3並添加了具有所需屬性的模型驗證。然後我創建了具有jQuery對話框的頁面(不是Ajax對話框)。在這種情況下,驗證不起作用。但是,如果我把對話框中的HTML頁面,它工作正常。模型驗證在jQuery對話框中不起作用
有沒有人知道如何解決問題?
這裏是我的JavaScript:
$(document).ready(function() {
$("#registerDialog").dialog({ autoOpen: false, show: "blind", hide: "explode", modal: true, resizable: false, height: 570, width: 390 });
$(".headerButton").button();
$(".accountBtn").button();
$('ul').roundabout({ autoplay: 'false', autoplayDuration: 3000 });
$("#registerBtn").click(function() {
$("#registerDialog").dialog("open"); return false; });
$("#closeRegisterDialog").click(function() { $("#registerDialog").dialog("close");
});
$("#registerBtnSbmt").click(function() {
$("#registerForm").submit(); return false; });
})
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { id = "registerForm" }))
{
<div id="registerDialog" title="Регистрация">
@Html.LabelFor(x => x.FirstName)
<br/>
@Html.TextBoxFor(x => x.FirstName, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.FirstName)
<br/>
@Html.LabelFor(x => x.LastName)
<br/>
@Html.TextBoxFor(x => x.LastName, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.LastName)
<br/>
@Html.LabelFor(x => x.Email)
<br/>
@Html.TextBoxFor(x => x.Email, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.Email)
<br/>
@Html.LabelFor(x => x.Password)
<br/>
@Html.TextBoxFor(x => x.Password, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.Password)
<br/>
@Html.LabelFor(x => x.ConfirmPassword)
<br/>
@Html.TextBoxFor(x => x.ConfirmPassword, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.ConfirmPassword)
<br/>
@Html.CheckBoxFor(x => x.RememberYou) запомнить Вас?
<br/>
<br/>
@Html.ActionLink("Сохранить", "LogIn", "Account", null, new { @class = "accountBtn", style = "font-size: 0.8em;", id = "registerBtnSbmt" })
<a href="#" class="accountBtn" id="closeRegisterDialog" style = "font-size: 0.8em;">Закрыть</a>
</div>
}
你可以發佈你的代碼用於生成對話框 – 2012-02-08 19:02:30
$(文件)。就緒(函數(){ $( 「#registerDialog」)對話框({ 的AutoOpen:假, 顯示: 「盲」, 隱藏: 「爆炸」, 模態:真, 可調整大小:假, 高度:570, 寬度:390 }); – Radislav 2012-02-08 19:11:51
$(「。headerButton」)。button(); $(「。accountBtn」)。button(); $('ul')。環島({autoplay:'false',autoplayDuration:3000}); (「#registerBtn」)。click(function(){(「#registerDialog」)。dialog(「open」); return false; }); (「#closeDialog」)。dialog(「close」); }); (「#registerBtnSbmt」)。click(function(){0}(「#registerForm」)。submit(); return false; }); }); – Radislav 2012-02-08 19:12:02