我如何检测 jQuery 验证何时完成,并根据该事件调用某些内容?
我是 jQuery 新手。
使用 jQuery 验证插件 &同时,cufon 也给我带来了很大的困难。
基本上,我想在 jQuery Validation 完成它必须做的事情后检测事件,并在它之后立即调用 Cufon.refresh() 。
$('#commentForm').validate({
rules: {
password: {
required: true,
minlength: 8,
maxlength: 8,
number: true
},
}
});
我们期待 。
创建后,我想在 jQuery 验证创建的标签上使用 Cufon.refresh() 。 如何检测 jQuery 验证何时完成,并根据该事件调用某些内容?
非常感谢任何帮助。 问候, 皮奥特尔
I'm new to jQuery.
Working with jQuery validation plugin & cufon at the same time is giving me really hard time.
Basically, I want to detect event once jQuery Validation did what it had to do and call Cufon.refresh() straight after it.
$('#commentForm').validate({
rules: {
password: {
required: true,
minlength: 8,
maxlength: 8,
number: true
},
}
});
We are expecting <label class="error"> SOME TEXT </label>
when form is not valid.
And once that created I want to Cufon.refresh() on that label created by jQuery Validation.
How can I detect when jQuery Validation is done, and call something based on that event?
Any help much appreciated.
Regards,
Piotr
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
感谢@Ariel - 如果有“成功”,那么也必须有“不成功”,所以..
工作代码:
再次感谢您的想法!
Thanks to @Ariel - if there is a 'success' there has to be a 'not-success' as well, so..
Working code:
Thanks again for the idea!
使用
success
选项:请注意,密码对象的右大括号后面有一个额外的逗号。这会在 IE 中出现错误。
Use the
success
option:Note that you have an extra comma after the close brace for the password object. This will give an error in IE.
这将允许您在验证完成后执行代码。不过,您需要放置一个提交表单片段,因为它替换了默认处理程序。
编辑:
您可以使用其中任何一个来做您想做的事情。 commitHandler 允许您停止提交并执行代码(您可以在提交之前使用它来执行代码)或在提交后成功执行代码。
This will allow you to execute code upon the completion of the validate. you will need to place a submit form snippet though, since it replaces the default handler.
EDIT:
You can use either to do what you want. submitHandler allows you to stop the submit and execute code instead ( you can possibly use it to perform code BEFORE you submit it ) or success to execute code after the submit.
将其放在
errorPlacement
选项中。Put it inside the
errorPlacement
option.