1

The View Model:

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
[Required(ErrorMessage = "*")]
public DateTime? TransferDate { get; set; }

The Javascript

$("#TransferDate").datepicker({ dateFormat: 'mm/dd/yy' });

The View

 @Html.EditorFor(model => model.TransferDate)

Although I have also change the culture information in Web.Config

<globalization uiCulture="en-US" culture="en-US"/>

Reference to this post validating date format not working

But still validation is coming false and Model Value coming NULL.

Kindly Suggest me some solution

Community
  • 1
  • 1
Sana Khan
  • 11
  • 1
  • what error does it throw ? Are you checking ModelState.IsValid ??? – Ganesh Kodiganti Nov 25 '14 at 06:51
  • Is this rendering your jquery datepicker or the browsers? I suggest you use `@Html.TextBoxFor(m => m.TransferDate)` so there is no chance of a conflict. –  Nov 25 '14 at 06:57
  • yes! I am checking ModelState.IsValid which is coming false. also I have used @Html.TextBoxFor(m => m.TransferDate) but nothing change happened. In ModelState.IsValid **TransferDate** value is coming null. – Sana Khan Nov 25 '14 at 07:25
  • please get more your code (code from controller and view) – isxaker Nov 25 '14 at 07:47
  • What is the value you have in the textbox? What is the value that is transferred in the request to the server (use something like Fiddler to capture it)? Note that in js, you have a two-digit year while in the model, you use four digits. – Hans Kesting Nov 25 '14 at 10:10
  • validation is coming false,validation error is **The value '11/21/2014' is not valid for TransferDate**. In controller, ModelState.IsValid is false,**TransferDate** value is coming **null**. – Sana Khan Nov 25 '14 at 11:14

0 Answers0