Jquery datepicker format date not working

后端 未结 12 2121
我在风中等你
我在风中等你 2021-01-01 22:23

Here is my code:

$(function () {
    $(\"#datepicker\").datepicker({ dateFormat: \'DD-MM-YY\' });
});

And the datetime picker is shown, but

12条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 23:16

    C#:-

     [Column(TypeName = "date")]
            [Display(Name = "Date of Birth")]
            [Required]
            [DataType(DataType.Date)]
            [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
            public DateTime? DOB { get; set; }
    

    CSHTL:-

     @Html.EditorFor(model => model.DOB, new { htmlAttributes = new { @class = "form-control" , @required = "required", @autocomplete="off"} })
    
            $(document).ready(function () {
            var validationerror = false;
             $('input[type=date]').datepicker({
                 dateFormat: "yy-mm-dd",
                 changeMonth: true,
                 changeYear: true,
                 yearRange: "-60:+0"
             });
    

提交回复
热议问题