自定义验证不适用于 Ajax MVC 调用
单击按钮时,如果同一页面(不是灯箱)中的另一个表单有效,我想提交一个表单。该验证是我创建的自定义验证并且工作正常。 这是视图中的代码
$("#btnSave").click(function (e) {
if ($("#GeneralButtonFrm").valid()) {
$("#ButtonFrm").submit();
} else {
//Error Message
} });
问题是提交操作正在执行,而没有等待返回 false 的自定义验证的响应。
知道为什么会发生这种情况吗?
注意:我说我没有使用 ligthbox 渲染部分,因为在这种情况下,解决方案将是 jQuery.validator.unobtrusive.parse('#form');
谢谢
On the click of a button i want to sumbit a form if another form, in the same page (not a ligthbox) is valid. That validation is a Custom Validation I created and is working fine.
This is the code in the view
$("#btnSave").click(function (e) {
if ($("#GeneralButtonFrm").valid()) {
$("#ButtonFrm").submit();
} else {
//Error Message
} });
The problem is that the submit action is executing without waiting for the response of the custom validation which return false.
Any idea why this is happening?
Note: I said I am not using a ligthbox rendering a partial becouse in that case the solution would be jQuery.validator.unobtrusive.parse('#form');
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的问题还是很模糊。但我认为你想要的是调用 ajax 并进行服务器端验证。如果是这样,问题是您的验证将在 ajax 请求之前返回,因为 ajax 请求是异步的。
You are still very vague, in your question. But i think what you want is to call ajax and do a serverside validation. If so, the problem is that your validation will return before ajax request since the ajax request is async.. Do this