Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# JQuery.valid()方法的日期验证问题_C#_Jquery_Asp.net Mvc_Kendo Asp.net Mvc - Fatal编程技术网

C# JQuery.valid()方法的日期验证问题

C# JQuery.valid()方法的日期验证问题,c#,jquery,asp.net-mvc,kendo-asp.net-mvc,C#,Jquery,Asp.net Mvc,Kendo Asp.net Mvc,我试图将jquery日期估值更改为en GB文化,但没有成功。 例如,对于2013年3月23日,我希望输入2013年3月23日,而不是2013年3月23日 当我调用表单上的验证方法时,它返回false。我没有从Kendo那里得到验证错误,只是从jquery方法中得到 如何更改jQuery的区域性设置 <script src="@Url.Content("~/Scripts/Kendo/cultures/kendo.culture.en-GB.min.js")"></script

我试图将jquery日期估值更改为en GB文化,但没有成功。 例如,对于2013年3月23日,我希望输入2013年3月23日,而不是2013年3月23日

当我调用表单上的验证方法时,它返回false。我没有从Kendo那里得到验证错误,只是从jquery方法中得到

如何更改jQuery的区域性设置

<script src="@Url.Content("~/Scripts/Kendo/cultures/kendo.culture.en-GB.min.js")"></script>
<script>kendo.culture("en-GB");</script>
...
@(Html.Kendo().DatePickerFor(model => model.OrderDate).HtmlAttributes(new { style = "width:150px", required = "required"  }).Culture("en-GB").Format("dd/MM/yyyy"))
...
var isValid = $("#orderForm").valid();   // returns false if I select 23/3/2013

谢谢。

将其放入脚本中,然后从这里获取正则表达式:


这是WebKit浏览器和jQuery验证的一个已知问题。它似乎已经向团队提出,但许多用户仍在报告问题

有几种方法可以调试和解决这个问题。首先尝试覆盖jQuery验证,以确保这实际上就是您看到的问题:

jQuery.validator.methods["date"] = function (value, element) { return true; }
或者,通过查找以下函数来破解jquery.validate.js:

date: function (value, element) 
请注意,$.browser现在已被弃用,下面将说明一种可能的方法:

if ($.browser.webkit) {
    var d = new Date();
    return this.optional(element) || !/Invalid|NaN/.test(new Date(d.toLocaleDateString(value)));
}
else {
    return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
}

我得到一个未捕获的正则表达式TypeError异常。我已经在上面的链接中尝试了前两个正则表达式。您必须在javascript中把/放在它的末尾和开头。这个/regex/我已经试过了以下几次,但我仍然得到了一个类型错误例外:我仍然得到了一个类型错误错误异常:我仍然得到了一个类型错误异常:var dateRegex='/这个/这个/regex/我已经试过了以下几次,但我仍然试过了以下几次,但我仍然得到了一个类型错误例外:我仍然得到了一个类型错误错误例外:var dateRegex=“/^0[1-1-9[1-9[12][[12][0-0-0[12][0-0-0 0-8[12][0-0-8][[1-1-1-1-9]1-1-9]1-1-1-1-1-9 9]1-1-1-1-9 9]12/12412412 12]1[1-1-1-1-1-9]1-1-9]1-12 12;1[1[1-12 12 12 12 12 12 12 16 | 20 | 24 | 28 | 32 | 36 | 40 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96$/|;你不需要撇号,把它去掉。谢谢。但我在所有普通浏览器中都遇到了这个问题,不仅仅是WebKit浏览器。
if ($.browser.webkit) {
    var d = new Date();
    return this.optional(element) || !/Invalid|NaN/.test(new Date(d.toLocaleDateString(value)));
}
else {
    return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
}