jQuery验证点击不提交 [英] jQuery Validation on click without submit

查看:132
本文介绍了jQuery验证点击不提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个惊人的脚本来验证我的表单和正常的功能,它的工作效果很好,但是我想验证onClick(a href)事件上的表单而不是submit(输入)..这是可能的?



脚本:
https:/ /github.com/jzaefferer/jquery-validation



一定是这样的吧?

 < a href =#onClick =validate()> 


解决方案

您可以调用 valid()方法来查看它是否有效。

 < a href =#onClick =$('myformselecto')。valid()> 

我建议使用jQuery添加处理程序而不是内联它

I am using this amazing script for validating my form and for the normal functionality it works great, but I would like to validate the form on a onClick (a href) event instead on the submit (input).. is that possible?

Script: https://github.com/jzaefferer/jquery-validation

It must be something like this, right?

<a href="#" onClick="validate()" >

解决方案

You can call the valid() method on the form to see whether it is valid.

<a href="#" onClick="$('myformselecto').valid()" >

I would recommend adding the handler using jQuery rather than inlining it

这篇关于jQuery验证点击不提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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