让 jquery.validate {ignore: } 适用于字段集内容

发布于 2024-09-19 21:26:37 字数 448 浏览 2 评论 0原文

我正在使用表单的 jQuery.validate() 插件。但是,表单包含一个字段集(它是隐藏的,并用作向表单添加行的模板),我不想对其进行验证。该字段集将被命名为类似于 organization_contacts_tmpl_33 的名称,其中不变量是 _tmpl_ 部分。我已经尝试过:

$('#myform').validate({
  debug: true,
  ignore: '[id*="_tmpl_"] input'
  });

我什至将字段集中的字段重命名为以 tmpl_ 开头,并尝试过:(

$('#myform').validate({
  debug: true,
  ignore: '[id^="tmpl_"]'
  });

及其多种变体)但无济于事。有什么想法吗?

I'm using the jQuery.validate() plugin for a form. However the form contains a fieldset (which is hidden, and used as a template for adding rows to the form) which I don't want to be validated. The fieldset will be named something like organisation_contacts_tmpl_33 with the invariant being the _tmpl_ part. I've tried:

$('#myform').validate({
  debug: true,
  ignore: '[id*="_tmpl_"] input'
  });

I've even renamed the fields inside the fieldset to start with tmpl_ and tried:

$('#myform').validate({
  debug: true,
  ignore: '[id^="tmpl_"]'
  });

(and multiple variations thereof) but to no avail . Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

世界等同你 2024-09-26 21:26:37

为什么不忽略隐藏的元素呢?

$('#myform').validate({
  debug: true,
  ignore: ':hidden'
});

Why don't you just ignore hidden elements?

$('#myform').validate({
  debug: true,
  ignore: ':hidden'
});
浮萍、无处依 2024-09-26 21:26:37

它只是一个 jQuery 选择器,它希望看到 文档

这应该可以工作。 。

  $('#myform').validate({
    debug: true,
    ignore: '#fieldset_id input'
  });

its just a jQuery selector that it expects see the documentation

this should work...

  $('#myform').validate({
    debug: true,
    ignore: '#fieldset_id input'
  });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文