In my mvc4 application, if I select a date greater than 12, I get a "Date is invalid" error. It works well for a date less than 12 .. The format obtained when selecting a date in datepicker is "mm / dd / yyyy". My model: -
[Required(ErrorMessage = "Date Of Birth is required")] [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")] [Display(Name = "Date Of Birth")] public DateTime? DOB{ get; set; }
Script for datepicker: -
<script type="text/javascript"> $(document).ready(function () { debugger; $('.datepicker').each(function () { $(this).removeClass('hasDatepicker').datepicker(); $(this).datepicker(); }); }); </script>
Please tell me the solution for this. Thanks..
source share