show your form. as a date time is not nullable, its required by default.
Annotation [Required] for the DateTime in class model
Hi,
I want to put the data annotation for the DateTime but it is not taken into account
[Required]
public DateTime DateCrea { get; set; }
i.e. in my application if I don't enter a value I can validate my page (e.g. creation).
Do you have any idea where the problem comes from? Should I add something specific for the DateTime?
Thanks in advance
2 answers
Sort by: Newest
-
-
sblb 1,166 Reputation points
2022-09-29T15:42:15.46+00:00 Are you asking about an Entity Framework class model
yes
A View model in your Blazor application?
yes
Model binding in Web API?
no
Is DateCrea a column in a table ... are you expecting a required user message in a Blazor application?
yes, I expect a message, so the user must fill in the DateCrea field.