I am using the following for displaying the date field in my razor view form:
@Html.TextBoxFor(m => m.LectureDate, "{0:dd/MM/yyyy}")
Which should allow the date format to be displayed in format 21/04/2017
, which is what is being supplied through JQuery DatePicker, but after it is set to this by datepicker and the form is submitted, the MVC Validation throws error and does not allow to submit the form.
I have tried applying <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-GB" uiCulture="en-GB" />
in Web.Config
. I have tried adding the data annotations attributes specified in the answers suggested.
And I have also tried specifying the format in the Html Helper only. But, still the MVC throws error and does not submit the form.
How can this be done?