I am working in MVC. I have used jQuery datepicker on my "Date" control.The jquery code for calling datepicker is given below:
$(document).ready(function () {
$('.date').datepicker({ dateFormat: "dd/mm/yy" });
});
My DateTime Partialview is :
@Html.TextBoxFor(x => x.Value, new { id = Model.Name, name = Model.Name, @class = "date", @readonly = true })
and my DateTimeViewModel properties are :
public string Name { get; set; }
public DateTime? Value { get; set; }
I am using this partial view in a form. Once i completely fill up my form and click on submit, the focus again goes to my datepicker to again pick up the date. It happens again and again and my form become unable to submit. I debug this control on chrome and the i noticed that date is not valid as given below:-
<input class="ff date hasDatepicker input-validation-error" data-val="true" data-val-date="The field Value must be a date." name="Fields[Lea_ex1_47].Value" readonly="True" type="text" value="" id="dp1369308655980">
EDIT Sorry for mentioning it late but i also observed it now. My datepicker taking the date from 1 to 12 of each month only. That is: Out of 30/31 days it will take the date from 1 to 12 (validate true) and other 13 to 31 giving validation error(validate false).
Kindly give me reason why this is happening? and how can i get rid of this?
Thanks in advance..
readonly = true?