jQuery unobtrusive validation and custom date formats
Another quick reminder for my sloppy memory:
in case you want to use a custom date format and you need validation (of course, why wouldn’t you?), sometimes may happen that the format you’re using is not recognised during the client validation phase.
In one of my side projects for example I am using the standard jquery unobtrusive validation along with globalize.js. Obviously I have a specific bundle configured for this:
[csharp]
var scriptBundle = new ScriptBundle(“~/bundles/validation”).Include(
“~/Scripts/jquery.validate.js”,
“~/Scripts/jquery.validate.unobtrusive.js”,
”~/Scripts/globalize/globalize.js”,
“~/Scripts/globalize/globalize.it-IT.js”,
“~/Scripts/jquery.validate.globalize.js”
);
[/csharp]
In case you have not noticed, I have imported the Italian globalization script. Again, in case you don’t know, in Italy the date format is usually “day/month/year”, or specifically dd/MM/yyyy .
In order to make client validation work, all you have to do is include somewhere in your project this script:
[csharp]
[/csharp]
that’s it!
Next time: server-side pagination and AngularJs!