MVC 5 client side validation culture

I changed the culture in my Web.config file to es-CL, and the server side validation is working well, but when I'm trying to submit the data the client side validation throws an error for dates like 25/11/2016 because it's still using the English date format like 11/25/2016.

I found this post which is about the same but with decimals instead date: MVC 3 jQuery Validation/globalizing of number/decimal field

The problem is all the answers there are outdated, because the newer globalization plugin doesn't use globalization files anymore, like globalize.culture.es-CL.js does not exists in the package. (Or I'm missing something?)

How can I set the client side validation culture to es-CL or es-MX?

Here is my View code:

        <div class="form-group">
            @Html.LabelFor(model => model.ReleaseDate, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @* i set the @type = "text" because i will use a Jquery DatePicker instead the browser's DatePicker, and the @class = datepicker adds the DatePicker. *@
                @Html.EditorFor(model => model.ReleaseDate, new { htmlAttributes = new { @class = "form-control datepicker", @type = "text" } })
                @Html.ValidationMessageFor(model => model.ReleaseDate, "", new { @class = "text-danger" })
            </div>
        </div>

Model for that input:

[Display(Name ="Fecha de emisión")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}",ApplyFormatInEditMode = true)]
public DateTime ReleaseDate { get; set; }

Controller action:

public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Movie movie = db.Movies.Find(id);
            if (movie == null)
            {
                return HttpNotFound();
            }
            return View(movie);
        }

Thanks.

Upvotes: 1

Views: 945

Answers (0)

Related Questions