I have an ASP.NET MVC form laid out something like this:
我有一个ASP。NET MVC表单展示了如下内容:
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "ccform" }))
{
@Html.ValidationSummary(true, "Please correct the errors and try again.")
<fieldset>
...
</fieldset>
}
I have some special processing for this form something like this:
我有一些特殊的处理方式是这样的:
$(function () {
$('#ccform').submit(function (e) {
e.preventDefault();
if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
}
if (Page_IsValid) {
...
}
});
});
But I'm finding that Page_ClientValidate is always undefined.
但是我发现Page_ClientValidate总是没有定义。
Searching the web, I see that this can be the case when the validation components are not available. But it seems that I everything that's needed for that.
在web上搜索,我发现当验证组件不可用时,可能会出现这种情况。但似乎我所做的一切都是需要的。
Can anyone offer some tips?
有人能提供一些建议吗?
EDIT
编辑
As indicated by Nathan, I was off-track. In my Google search, I ended up looking at WebForm validations. It turns out the answer is amazingly simple in MVC.
如Nathan所示,我偏离了正轨。在谷歌搜索中,我最终查看了WebForm验证。在MVC中,答案非常简单。
if ($('#ccform').valid()) {
}
Nice.
好了。
1 个解决方案
#1
2
Page_ClientValidate()
is part of ASP.NET Webforms validation, and it is not used with ASP.NET MVC. You will have to use something like jQuery Validation for your ASP.NET MVC input validation.
Page_ClientValidate()是ASP的一部分。NET Webforms验证,它不用于ASP。净MVC。您将不得不为您的ASP使用jQuery验证之类的东西。净MVC输入验证。
#1
2
Page_ClientValidate()
is part of ASP.NET Webforms validation, and it is not used with ASP.NET MVC. You will have to use something like jQuery Validation for your ASP.NET MVC input validation.
Page_ClientValidate()是ASP的一部分。NET Webforms验证,它不用于ASP。净MVC。您将不得不为您的ASP使用jQuery验证之类的东西。净MVC输入验证。