使用jQuery Validator插件验证表单,但是从链接触发它 [英] Validate a form with jQuery Validator plugin but trigger it from a link

查看:124
本文介绍了使用jQuery Validator插件验证表单,但是从链接触发它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,
我正在尝试使用jQuery Form Validator(http://docs.jquery.com/Plugins/Validation)。但是,我希望能够单击链接进行验证,然后在一切正常的情况下提交表单。有谁知道如何做到这一点?任何提示或建议将不胜感激。

All, I'm trying to use the jQuery Form Validator (http://docs.jquery.com/Plugins/Validation). However I'd like to be able to click a link to do the validation and then submit the form if everything is ok. Does anyone know how to do this? Any tips or suggestions would be greatly appreciated.

谢谢!

推荐答案

完全可能。插件文档甚至给出一个示例,我已经修改了一点来提交警报:

Totally possible. The plugin docs even give an example, which I've modified a little bit to submit instead of alert:

$("#myform").validate();
$("a.check").click(function() {
  if ($("#myform").valid()) {
    $("#myform").submit();
  }
  return false;
});

这篇关于使用jQuery Validator插件验证表单,但是从链接触发它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆