I want to add globalization because the site asks the user for a date. And my german user want to type "31.12.1966" and not "1966-12-31".
So I add the nuget-Packages "jQuery.Validation.Globalize" and "jquery-globalize" to the project.
Now I am not able to configure my BundleConfig! From my research I know, that I Need globalize.js and some other files. So I try to make a bündle:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
bundles.Add(new ScriptBundle("~/bundles/global").Include(
"~/Scripts/globalize.js",
"~/Scripts/cldr.js").IncludeDirectory("~/Scripts/cldr/",
"~/Scripts/globalize/")
);
The using in the view:
...
@section Scripts {
@Scripts.Render("~/bundles/global")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/unobtrusiveajax")
<script type="text/javascript">
$(function () {
$.validator.methods.date = function (value, element) {
Globalize.culture("de-DE");
// you can alternatively pass the culture to parseDate instead of
// setting the culture above, like so:
// parseDate(value, null, "en-AU")
return this.optional(element) || Globalize.parseDate(value) !== null;
}
});
</script>
}
But I get an error:
Error at line 9, column 5 in http://localhost:58289/Scripts/jquery.validate.globalize.js
0x800a138f - runtimeerror in JavaScript:
The property "methods" of a undefindes or null-pointer can not bei called
I translated the message from this german original:
Ausnahmefehler in Zeile 9, Spalte 5 in http://localhost:58289/Scripts/jquery.validate.globalize.js
0x800a138f - Laufzeitfehler in JavaScript:
Die Eigenschaft "methods" eines undefinierten oder Nullverweises kann nicht abgerufen werden.
Need I more/other files in the bundle?
What can I do? Any help?
Sincerly Peter