ajax.beginform 和 xVal
我正在使用 Ajax.BeginForm 提交表单并使用 xVal 来强制验证
即使表单有错误,也会发出 ajax post 请求。我知道客户端验证正在工作,因为它显示了正确的错误消息,但为什么它认为可以发出 ajax 请求,我不明白。
我什至尝试将 causesvalidation = true 放入提交选项卡中,但表单仍在提交中。
<% using (Ajax.BeginForm("SuggestTemp", new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "Result" }))
{%>
<table>
<tr>
<td style="text-align:right">
Title
</td>
<td>
<%= Html.TextBox("Upload.Title")%>
<%= Html.V
alidationMessage("Upload.Title")%>
</td>
</tr> <tr><td><%=Html.ClientSideValidation<Upload>("Upload") %></td><td></td></tr>
<tr><td></td><td><input type = "submit" causesvalidation = "true" value = "Suggest " class = "btn"/></td></tr>
</table>
<div id = "Result"><%=ViewData["SuggestStatus"]%></div>
I am using Ajax.BeginForm to submit a form ans xVal to enforce validation
The problem the ajax post request is being made even when the form has errors on it. I know client-side validation is working, because it is displaying proper error messages and what not, but why it thinks it is okay to make the ajax request anyway is something I don't understand.
I even tried putting causesvalidation = true
inside the submit tab, but the form is still being submitted.
<% using (Ajax.BeginForm("SuggestTemp", new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "Result" }))
{%>
<table>
<tr>
<td style="text-align:right">
Title
</td>
<td>
<%= Html.TextBox("Upload.Title")%>
<%= Html.V
alidationMessage("Upload.Title")%>
</td>
</tr> <tr><td><%=Html.ClientSideValidation<Upload>("Upload") %></td><td></td></tr>
<tr><td></td><td><input type = "submit" causesvalidation = "true" value = "Suggest " class = "btn"/></td></tr>
</table>
<div id = "Result"><%=ViewData["SuggestStatus"]%></div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将
$("#yourFormId").validate()
放入OnBegin
参数中,例如:
try to put
$("#yourFormId").validate()
to theOnBegin
parameterEx: