结合 jQuery 验证器插件调用 blockUI 和 unblockUI
我有一个非常复杂的表单,验证工作正常。但是,由于验证可能需要一段时间才能完成,因此我想在单击表单的提交按钮时调用 blockUI,以防止混淆和重复提交。我不太清楚该怎么做。
我的代码如下所示:
$("#credential").validate({
rules: {
EngId: {
required: true
}
ClientAccount: {
required: true
}
...
}
我根据表单中的选择使用多个按钮(使用它们的单击功能)调用验证,通常会禁用某些规则:
$("#buttonname").click(function() {
$("#fieldname").rules("remove");
...
$("#credential").submit();
});
我不明白的是 blockui 和 unblockui 调用的位置这样,当用户单击按钮时,在验证开始之前,blockui 会发挥其魔力,如果验证发现问题,则会调用 unblockui 并再次启用表单。
我对 Jquery 还很陌生,我找不到任何我能够成功实现的示例。我将不胜感激任何人可以提供的帮助(如果之前已经介绍过,请原谅)。
I have a very complex form with the validation working correctly. However, since it can take awhile for the validation to complete, I'd like to use blockUI to be called when I click the form's submit button to prevent confusion and double-submissions. I can't quite figure out how to do this.
My code looks like this:
$("#credential").validate({
rules: {
EngId: {
required: true
}
ClientAccount: {
required: true
}
...
}
and I'm calling the validation with several buttons (using their click function) depending on selections in the form, often disabling some of the rules:
$("#buttonname").click(function() {
$("#fieldname").rules("remove");
...
$("#credential").submit();
});
What I can't figure out is where the blockui and unblockui calls would go so that when the user clicks the button, before validation starts, blockui does its magic, and if the validation finds a problem, unblockui is called and enables the form again.
I'm pretty new to Jquery and I can't find any examples that I've been able to implement successfully. I would appreciate any help anyone could give (please excuse if this has been covered before).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我整理了一个页面来演示带有验证的工作表单, blockui 和动态规则。
I put together a page to demonstrate a working form with validate, blockui, and dynamic rules.