Hi,
I want to add Jquery date picker to MVC Form.
I get the datepicker but on the Form the Date don't empty and have default value 01/01/0001.
I want a date calendar to be appear when user clicks the form on Spanish language.
Please help in using date picker with jquery.
My code as follows.
@Html.EditorFor(m => m.myDate, new { htmlAttributes = new { @class = "textarea", placeholder = "Date", @readonly = "true" } })
@Html.ValidationMessageFor(m => m.myDate, "", new { @class = "text-danger" })
@section Scripts {
@Scripts.Render("~/bundles/jqueryui")
@Styles.Render("~/Content/cssjqryUi")
<script type="text/javascript">
$(document).ready(function () {
$('input[type=datetime]').datepicker({
dateFormat: "dd/mm/yy",
changeMonth: true,
changeYear: true,
yearRange: "-2:+0"
});
});
</script>
}
public class PersonModel
{
[Required]
[Display(Name = "the date")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime myDate { get; set; }
}