Filip
Filip

Reputation: 1097

asp.net mvc datetime format in browser

I have a jQuery datetime picker.

This is the property of the model:

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
[DisplayName("Birth date (DD/MM/YYYY)")]
public DateTime? BirthDate { get; set; }

The code in the view:

@Html.TextBoxFor(m => m.Employee.BirthDate, new { @class = "dpTextBox" })

some javascript:

$(".dpTextBox").datepicker({
                changeMonth: true,
                changeYear: true,
                dateFormat: 'dd/mm/yy'
            });
$.datepicker.setDefaults($.datepicker.regional['nl']);

In Internet Explorer, it works fine. In Chrome it doesn't. The validation error is "The field Birth date (DD/MM/YYYY) must be a date." The language of Chrome is English. When I change the language to Dutch, it works fine, but I want the UI of Chrome in English...

Upvotes: 0

Views: 1351

Answers (2)

Filip
Filip

Reputation: 1097

When I delete the following piece of code, it works fine...

@Scripts.Render("~/bundles/jqueryval")

It has something to do with this library

Upvotes: 0

user1713815
user1713815

Reputation:

@{Html.Telerik().DatePickerFor(model => model.BlogDate)
                    .Name("BlogDate")
                    .HtmlAttributes(new { id = "DatePicker_wrapper" })
                    .OpenOnFocus(true)
                    .Render();              
            }

use Telerik datepicker

Upvotes: 1

Related Questions