When submitting a form with a dd / MM / yyyy date, the value is converted to the US format in the controller, leaving MM / dd / yyyy. Through the response question , I configured globalize to solve this problem. However, the error persists.
The following bundle is configured:
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate.js",
"~/Scripts/jquery.validate.globalize.js",
"~/Scripts/jquery.validate.unobtrusive.min.js",
"~/Scripts/jquery.unobtrusive-ajax.js"));
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/globalize").Include(
"~/Scripts/globalize.js"));
Code to load the bundles
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/globalize")
@Scripts.Render("~/bundles/jqueryval")
Configuration line in section System.Web
in Web.Config
<globalization uiCulture="pt-BR" culture="pt-BR" enableClientBasedCulture="true" requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8" />
Datetime field in cshtml
@Html.TextBoxFor(model => model.Inicio, "{0:dd/MM/yyyy}", new { @class = "form-control" })