Home > Software engineering >  'flatpicker' datepicker model validation not working in asp.net mvc core
'flatpicker' datepicker model validation not working in asp.net mvc core

Time:07-08

I have used flatpicker datepicker. In this field asp.net model validation is not working.

<div >
   <label asp-for="txtDate" >From Date</label>
   <input asp-for="txtDate" type="text"  placeholder="DD-MMM-YYYY" />
   <span asp-validation-for="txtDate" ></span>
</div>


$("#txtDate").flatpickr({
    format: "d-m-Y",
    altFormat: "d-M-Y",
    minDate: new Date(),
    altInput: true,
});

[Required(ErrorMessage = "Enter Start Date")]
public string? txtDate { get; set; }

CodePudding user response:

I have found the solution. It is working properly.

$("#txtDate").flatpickr({
    dateFormat: "d-M-Y"
});
  • Related