有效性插件jquery问题?
我正在使用 有效性插件 来验证表单。它工作正常,但是如果有效性函数成功,是否可以执行回调函数,如下所示,
$("form").validity(function(){
$("#place").require().range(3, 50);
$("#location").require().greaterThan(4)
}, function(){ /* Here to put the call back code */ });
因为如果表单验证成功,我想运行一些代码,任何想法将不胜感激
I'm using the validity plugin to validate a form. It's working fine but is it possible to execute a callback function if the validity function succeeded like the following
$("form").validity(function(){
$("#place").require().range(3, 50);
$("#location").require().greaterThan(4)
}, function(){ /* Here to put the call back code */ });
because i want to to run some code if the form validation successes , Any idea would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据文档,这并不容易实现。
但是,您也许可以编写一个执行回调的自定义“输出模式”: http: //validity.thatscaptaintoyou.com/Demos/index.htm#CustomOutputMode
According to the docs it's not easily possible.
However, you might be able to write a custom "output mode" that executes your callback: http://validity.thatscaptaintoyou.com/Demos/index.htm#CustomOutputMode
您可以使用 validate.start / validate.end 方法 -> http://validity.thatscaptaintoyou.com/Demos/index.htm#UsingValidityWithAjax
它看起来像这样(未经测试!):
You could use the validate.start / validate.end method -> http://validity.thatscaptaintoyou.com/Demos/index.htm#UsingValidityWithAjax
it would look something like this (untested!):
好的,有效性支持可插入的“输出模块”。
这是一个(诚然是黑客且未经测试的)将调用您的回调函数。只需将代码附加到 jquery.validity.outputs.js 或将其放入您自己的文件中,以便在有效性后加载。
用法:
Okay, validity supports pluggable "output modules".
Here's one (admittedly hacky and untested one) that will call your callback function. Just append the code to jquery.validity.outputs.js or put it into your own file that you load after validity.
Usage:
通常你可以做这样的事情:
当然使用这种模式你可以实现你的js对象,这会更方便使用。
Normally you can do this kind of stuff like this:
Of course using this pattern you are able to implement you js object which would be more convienent to use.