I'm trying to make a simple login form in ASP.NET Core Razor Pages, which has an email address field, a password field, a login button and a forgot-password button.
I want to utilize the inbuilt client-side and server-side validation on the text fields, such that the email field is required for both button submissions, but the password field is only required for login button submission.
Decorating the model properties with a [Required]
attribute makes them mandatory for all form post handlers, where-as I'm looking for some way to have conditional model binding, either programmatically or through an attribute on model properties or handler method parameters.
Is it possible to define conditional model binding to achieve this, or is there a clean & simple alternative?