The following line does nothing:
$.datepicker.setDefaults($.datepicker.regional['en-GB']);
if you did not specify the appropriate language file , which by default is not included in the ASP.NET MVC 4 template.
You can try to explicitly set the format:
$.datepicker.setDefaults({ dateFormat: 'dd/mm/yy' });
But this only applies to how the date should be formatted after it is selected in the datepicker. This has nothing to do with verification.
Client-side validation is performed by the jquery.validate
plugin, which, in turn, uses the currently configured culture (which can explain the inconsistencies that you observe between FF and IE, for example, you can configure to use en-GB and other en-US ) or ISO date.
You can override this custom check and use it in your custom format to ensure that it will work in a cross browser:
if (!Modernizr.inputtypes.date) { $(function () { $.datepicker.setDefaults({ dateFormat: 'dd/mm/yy' }); $('.datefield').datepicker(); }); jQuery.validator.addMethod( 'date', function (value, element, params) { if (this.optional(element)) { return true; }; var result = false; try { $.datepicker.parseDate('dd/mm/yy', value); result = true; } catch (err) { result = false; } return result; }, '' ); }
source share