使用基于远程属性的验证时必须双重提交
我们的模型上有一个具有 [Remote] 属性的字段。当我们将该字段存储在隐藏表单元素上然后尝试提交该表单时,我们必须单击提交按钮两次。同样有趣的是,我们第二次单击它时,没有发生远程验证(Fiddler 是这么说的)。
想法?
We have a field on our model which has a [Remote] attribute. When we store that field on a Hidden form element and then try to submit that form we have to click the submit button twice. Also interesting is that the 2nd time we click it no remote validation is occurring (so says Fiddler).
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无法重现。如果隐藏字段用 Remote 属性修饰,则无论您单击提交按钮多少次,如果远程函数发送
false
,您都将无法提交表单。例如:
Model:
Controller:
View:
因为远程函数总是返回 false,所以无法提交该表单。如果远程函数返回 true,那么单击一次就足以提交它,当然假设其他验证已通过。
Unable to repro. If the hidden field is decorated with the Remote attribute you won't be able to submit the form no matter how many times you click on the submit button if the remote function sends
false
.For example:
Model:
Controller:
View:
Because the remote function will always return false this form cannot be submitted. If the remote function returns true a single click would be enough to submit it assuming of course that the other validation passed.