1

I've set up a MvcContrib Grid with paging and filtering as described here. It all works great, except when I try to add filtering by date.

My web configuration includes:

<globalization
   uiCulture="en-GB"
   culture="en-GB"
/>

I'm using the jquery datepicker to enter the date:

<script type="text/javascript">
    $(function () {
        if (!Modernizr.inputtypes.date) {
            $.getScript("/Scripts/jquery-ui-1.8.11.min.js", function () {
                $("input[type='datetime']").datepicker({ dateFormat: "dd/mm/yy" });
            });
        }
    });
</script>

The dates show as dd/mm/yy during data entry in the filter. They show as dd/mm/yy in the controller. But in validation they are treated as mm/dd/yy.

Does anyone have any ideas?

John McArthur
  • 916
  • 1
  • 12
  • 30

2 Answers2

1

I had the same problem mate: JQuery Datepicker Will not post with UK date string

Personally I gave up and validated with javascript, and disabled the unobtrusive jquery, which I think where the conflict was coming from.

Although a poster on my question thread pointed this way, which could be useful:

http://www.hanselman.com/blog/GlobalizationInternationalizationAndLocalizationInASPNETMVC3JavaScriptAndJQueryPart1.aspx

Community
  • 1
  • 1
DevDave
  • 6,700
  • 12
  • 65
  • 99
1

Came back to this problem and got it working, thanks to the link to Scott Hanselman's Blog.

First I downloaded the jquery.global plugin from Nuget.Then I added the following lines to my _layout.cshtml

<script src="../../Scripts/jquery.globalize/globalize.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.globalize/cultures/globalize.culture.en-GB.js" type="text/javascript"></script>

and this to the system.web section of web.config:

<globalization
   uiCulture="en-GB"
   culture="en-GB"
/>

This has got it working for me.

John McArthur
  • 916
  • 1
  • 12
  • 30