I have a MVC core project with EF core data context. I've used scaffolding to create CRUD. I just want to know is there anyway to use my custom logic for parsing datetime in text box when the user hit save?
Currently I have this in Create page:
<div class="form-group col-md-6 col-xs-12">
<label asp-for="Lead.BDayDateTime" class="control-label"></label>
<input asp-for="Lead.BDayDateTime" class="form-control" />
<span asp-validation-for="Lead.BDayDateTime" class="text-danger"></span>
</div>
and its the definition in my model:
[Required(ErrorMessage = "Please enter year of birth or birthday (ex. 1363, 1984, 1984-09-23, 1363-07-01)")]
[Display(Name = "Birthday", Prompt = "Birth Year or Birthday", Description = "Please enter year of birth or birthday (ex. 1363, 1984, 1984-09-23, 1363-07-01)")]
[DisplayFormat(NullDisplayText = "Not Entered", DataFormatString = "{0:yyyy}", ApplyFormatInEditMode = true)]
public DateTime BDayDateTime { get; set; }
I want to manually parse datetime, so the user can enter non-Gregorian datetime values (and I'll convert them to Gregorian before saving to database).