jQuery验证多个选择器以忽略 [英] jQuery Validation multiple selectors for ignore

查看:114
本文介绍了jQuery验证多个选择器以忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了jQuery验证问题,需要忽略一些字段.

I am running into a problem with jQuery Validation and need to ignore some fields.

我需要忽略基于我设置的类的字段,然后还要忽略所有隐藏的字段.我需要做的是以下操作,但这只是尊重第二个忽略.我假设有一种方法可以告诉jQuery验证这些多个选择器,但我似乎找不到它.

I need to ignore fields based on a class that I set and then also all hidden fields. What I need to do is the following, but it is only honoring the second ignore. I am assuming there is a way to tell jQuery Validation these multiple selectors but I cannot seem to find it.

validator = $("#form1").validate({
    onsubmit: false,
    ignore: ".ignore",
    ignore: ":hidden",

谢谢

蒂姆

推荐答案

来自验证文档:

使用jQuery的not-method,因此not()接受的所有内容都可以作为此选项传递.

jQuery's not-method is used, therefore everything that is accepted by not() can be passed as this option.

因此,您要做的就是传递一个参数,且选择器之间用逗号分隔:

Therefore all you need to do is pass one parameter with your selectors separated by commas:

validator = $("#form1").validate({
    onsubmit: false,
    ignore: ".ignore, :hidden"
});

这篇关于jQuery验证多个选择器以忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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