JQuery 验证器插件“日期”有效,但“dateDE”抛出错误
正如标题中基本解释的那样,我有一个带有日期字段的表单。这种存在于德国,我想根据提供的“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 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.