FYI... The "chrome" fix referred to in previous posts that uses a call to toLocaleDateString(value) doesn't really work. The toLocalDateString() method doesn't take any parameters, and the call just returns the current date, so the validation will always pass regardless of the validity of the entered date when using Chrome.
I think krainov's previous post making use of the globalize.js library is the best approach. You could also refer to the following article for more information... http://icanmakethiswork.blogspot.com.au/2012/09/globalize-and-jquery-validate.html. I believe there's also a work request open to integrate globalize support directly into the jquery.validate plugin in the future.
Basically to get this working in nopCommerce (v3.10) I did this...
Step 1. Updated Nop.Web/global.asax.cs to remove the override that forces the culture to en-US in the admin area, changing this...
if (webHelper.GetThisPageUrl(false).StartsWith(string.Format("{0}admin", webHelper.GetStoreLocation()),
StringComparison.InvariantCultureIgnoreCase))
{
//admin area
//always set culture to 'en-US'
//we set culture of admin area to 'en-US' because current implementation of Telerik grid
//doesn't work well in other cultures
//e.g., editing decimal value in russian culture
var culture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}
else
{
//public store
var workContext = EngineContext.Current.Resolve<IWorkContext>();
if (workContext.CurrentCustomer != null && workContext.WorkingLanguage != null)
{
var culture = new CultureInfo(workContext.WorkingLanguage.LanguageCulture);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}
}
...to this...
var workContext = EngineContext.Current.Resolve<IWorkContext>();
if (workContext.CurrentCustomer != null && workContext.WorkingLanguage != null)
{
var culture = new CultureInfo(workContext.WorkingLanguage.LanguageCulture);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}
Step 2. Added the globalize scripts to the scripts folder (globalize.js plus a "cultures" sub-directory along with all of the culture specific scripts you require). These are available here... https://github.com/jquery/globalize
Step 3. Added the jquery.validate.globalize library to the scripts folder. This is a specialised script that allows query.validate to make use of globalise.js for its date/number validation. It's available here... https://github.com/johnnyreilly/jquery-validation-globalize
Step 4. Updated _AdminLayout.cshtml to include the globalize scripts...
Html.AppendScriptParts("~/Administration/Scripts/admin.common.js");
Html.AppendScriptParts("~/Administration/Scripts/jquery.validate.globalize.min.js");
Html.AppendScriptParts("~/Administration/Scripts/jquery.validate.unobtrusive.min.js");
Html.AppendScriptParts("~/Administration/Scripts/jquery.validate.min.js");
Html.AppendScriptParts("~/Administration/Scripts/jquery.unobtrusive-ajax.min.js");
var globalizeCultureScript = string.Format("~/Administration/Scripts/cultures/globalize.culture.{0}.js", this.WorkContext.WorkingLanguage.LanguageCulture);
if (File.Exists(Request.MapPath(globalizeCultureScript)))
{
Html.AppendScriptParts(globalizeCultureScript);
}
Html.AppendScriptParts("~/Administration/Scripts/globalize.js");
Html.AppendScriptParts("~/Administration/Scripts/jquery-1.7.1.min.js");
Step 5. Updated _AdminLayout.cshtml to add a <script> to the head section to set the culture for globalize.js. We also need to override the date validation provided in the jquery.validate.globalize.js script because nopCommerce has combined date+time fields which are not supported by this script (it only seems to handle validation of date-only values).
<script>
// support validation of combined date+time fields
jQuery.extend(jQuery.validator.methods, {
date: function (value, element) {
return this.optional(element) ||
(Globalize.parseDate(value) instanceof Date) ||
(Globalize.parseDate(value, Globalize.culture().calendar.patterns.d + " " + Globalize.culture().calendar.patterns.t) instanceof Date);
}
});
$(document).ready(function () {
// Set Globalize to the current culture
Globalize.culture('@(this.WorkContext.WorkingLanguage.LanguageCulture)');
});
</script>
Step 6. Update the call to telerik.scriptregistrar() at the bottom of the _AdminLayout.cshtml to ensure globalization is enabled in the datepickers....
@(Html.Telerik().ScriptRegistrar()
.jQuery(false)
.jQueryValidation(false)
.Globalization(true)
)
Hope this helps!