Skip to content

ValidationMessage disappears on attempted form submit #17110

@katiep23

Description

@katiep23

Using Blazor with .NET Core 3.1 Preview.

Have a date picker inside of an EditForm model with a validation message:

<EditForm Model="@request" OnValidSubmit="@SubmitRequest">
        <ValidationSummary></ValidationSummary>
        <DataAnnotationsValidator />

<div class="field">
                <MatDatePicker Label="Need Date" @bind-Value="request.RequestedByDate"></MatDatePicker>
                <ValidationMessage For="@(() => request.RequestedByDate)" />
</div>

<MatButton Raised="true" Type="submit">Save</MatButton>
</EditForm>

This is a custom validation I created to make sure a date in the past is not chosen. The error message displays if incorrect date is chosen. However, if the form if the submit button is clicked, the form does not submit (correct), but the validationmessage for the field disappears.

I added the <ValidationSummary> tag up top to test. The error message stays present there even after button clicked. Just not in the Validation Message.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions