Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7801129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:51:11+00:00 2026-06-02T00:51:11+00:00

I have a regular form that gets POSTed to a controller. Dates must be

  • 0

I have a regular form that gets POSTed to a controller. Dates must be entered in the day/month/year format, since it’s an app for South America. I’m force setting the current culture UI to spanish-Peru. Tried with MVC 3 and 4 beta.

Here is the controller Code:

[HttpPost]
public ActionResult Create(EditPatientViewModel model)
{
   Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-PE");
   if (ModelState.IsValid) {
       // never reaches in here if date submitted as day/month/year
   }
}

When I debug and look at the ModelState errors, the culture inside of them is still set to en-US, even though I can verify the CurrentThread.CurrentUICulture is set to es-PE.

How do I make the ModelState validation also change?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:51:12+00:00Added an answer on June 2, 2026 at 12:51 am

    Set the globalization in your web.config to es-PE.

    <configuration>
       <system.web>
          <globalization fileEncoding="utf-8" 
                         requestEncoding="utf-8" 
                         responseEncoding="utf-8" 
                         culture="es-PE"
                         uiCulture="es-PE"/>
       </system.web>
    </configuration>
    

    And it should work fine, posting and validation.

    UPDATE

    If for any reason your ModelState is interpreting your Date incorrect you can do something like:

    ModelState[n].Value.Culture = {es-PE};
    

    before the validation occurs.

    UPDATE

    You can also change default binder and make your own.

    public class MyDateTimeBinder : IModelBinder
    {
      public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
      {
         var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
         var date = value.ConvertTo(typeof(DateTime), CultureInfo.CurrentCulture);
          return date;    
       }
    }
    

    Put

    ModelBinders.Binders.Add(typeof(DateTime), new MyDateTimeBinder());
    ModelBinders.Binders.Add(typeof(DateTime?), new MyDateTimeBinder());
    

    in the Application_Start() in the Global.asax.

    Regards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that contains a regular link as a submit button. Upon
I have a form that manipulates the size of an image that is posted
I have a form that people must fill in. There has to be checks
I have a form that I have used before that is just a regular
I have a regular matrix (non-sparse) that I would like to convert to a
I have a regular ViewController that contains a TableView. I am using storyboards to
I have this Regular Expression that matches the following strings: <!-- 09-02-2009 ---> <!--
I have an ASP.NET MVC 2 form that is working perfectly, doing client side
I have an array (for checkboxes) that I need to pass alongside the regular
I am have completed javascript validation of a form using Regular Expressions and am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.