没有提交按钮,如何直接使用jQuery Validate? [英] How do I use jQuery Validate directly, without the submit button?

查看:87
本文介绍了没有提交按钮,如何直接使用jQuery Validate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经进行了各种测试,并且发现jQuery validate函数仅适用于提交"按钮.

I have done various tests and I have found that the jQuery validate function works only with the submit button.

我是对的吗?如果是,该如何在没有提交按钮的情况下使用jQuery validate插件?

Am I right? If yes how can I use the jQuery validate plugins without the submit button?

推荐答案

您可以使用方法有效()直接调用验证器.

You can use the method valid() to invoke the validator directly.

它将返回布尔值,指示该表格是否有效.

It will return bool indicating whether the form is valid or not.

这是一个来自jQuery文档的示例:

Here is an example, from jQuery documentation:

$("#myform").validate();
$("a.check").click(function() {
    alert("Valid: " + $("#myform").valid());
    return false;
});

这篇关于没有提交按钮,如何直接使用jQuery Validate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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