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"
});