JQuery 验证器插件“日期”有效,但“dateDE”抛出错误

发布于 2024-09-18 08:34:54 字数 1069 浏览 1 评论 0原文

正如标题中基本解释的那样,我有一个带有日期字段的表单。这种存在于德国,我想根据提供的“dateDE”验证器来验证它。这是我的验证器代码

$("#aufuhrRecherche").validate({
   rules: {
     recherchegrund: "required",
     beginn: "dateDE",
     ende: "dateDE"
   },
   messages: {
     recherchegrund: "Bitte einen Recherchegrund angeben",
     beginn: "Bitte ein Anfangsdatum angeben",
     ende: "Bitte ein Enddatum angeben"
   },
   errorLabelContainer: "#error",
      wrapper: "li",       
      highlight: function(element, errorClass) {
          $(element).css('background-color', 'salmon');
       },
      unhighlight:function(element, errorClass) {
          $(element).css('background-color', 'white');
       }
  }
 );

现在使用此代码,我在 jquery.validator.js 中收到以下错误:

$.validator.methods[method] is undefined Line 492

使用

beginn: "dateDE",
ende: "dateDE"

效果很好,并且错误会在应该出现的漂亮列表中弹出。

这让我发疯。有人见过这个吗?

编辑

我刚刚尝试了与“dateISO”完全相同的代码并且它有效。我开始认为这是 jQuery 验证插件的一个错误。但还是很奇怪,我是唯一一个有这个问题的人。

As basicly explained in the title I have a form with a date field. This beeing in Germany and all I would like to validate it against the provided "dateDE" validator. Here is my validator code

$("#aufuhrRecherche").validate({
   rules: {
     recherchegrund: "required",
     beginn: "dateDE",
     ende: "dateDE"
   },
   messages: {
     recherchegrund: "Bitte einen Recherchegrund angeben",
     beginn: "Bitte ein Anfangsdatum angeben",
     ende: "Bitte ein Enddatum angeben"
   },
   errorLabelContainer: "#error",
      wrapper: "li",       
      highlight: function(element, errorClass) {
          $(element).css('background-color', 'salmon');
       },
      unhighlight:function(element, errorClass) {
          $(element).css('background-color', 'white');
       }
  }
 );

Now using this code I get the following error in jquery.validator.js:

$.validator.methods[method] is undefined Line 492

Using just

beginn: "dateDE",
ende: "dateDE"

works just fine and the error pop up in a nice list where they should.

This is driving me insane. Has anybody seen this before?

EDIT

I just tried the exact same code with "dateISO" and it works. I am starting to think this is a bug with the jQuery validation plug-in. But still strange that I am the only one that has this problem.

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

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

发布评论

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

评论(1

何处潇湘 2024-09-25 08:34:54

来自 jQuery 验证插件的 更改日志:“ dateDE 和 numberDE 方法已替换为 localization/methods_de.js 文件”。因此包含methods_de.js 文件。

From jQuery validate plugin's Change Log: "The dateDE and numberDE methods were replaced with a localization/methods_de.js file". So include methods_de.js file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文