© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
1 reply
Rese

❔ Custom validation attribute not displaying validation message

I'll butt in with a bit of a question. I'm using an EditForm in Blazor Server, where I directly pass it the EditContext and manually trigger the validation logic. Got a bit of an issue where if I validate something using a CustomAttribute, the validation result will blink for a bit in the validation message and then disappear. It's still there if I use a ValidationSummary, but not in the Validation Message for the specific field. Anyone got any idea why?

form:
<EditForm EditContext="_merchantContext" class="create-link-form">
            <DataAnnotationsValidator />

            <div class="form-control">
                <Name For="() => _merchant.EmailAddress" />
                <InputText type="text" @bind-Value="_merchant.EmailAddress" placeholder="example@example.com"/>
                <ValidationMessage For="() => _merchant.EmailAddress" />
            </div>

            <div class="form-control">
                <Name For="() => _merchant.Iban" />
                <InputText class="uppercase" type="text" @bind-Value="_merchant.Iban" placeholder="SKXX XXXX XXXX XXXX XXXX XXXX" />
                <ValidationMessage For="() => _merchant.Iban" />
            </div>
        </EditForm>
<EditForm EditContext="_merchantContext" class="create-link-form">
            <DataAnnotationsValidator />

            <div class="form-control">
                <Name For="() => _merchant.EmailAddress" />
                <InputText type="text" @bind-Value="_merchant.EmailAddress" placeholder="example@example.com"/>
                <ValidationMessage For="() => _merchant.EmailAddress" />
            </div>

            <div class="form-control">
                <Name For="() => _merchant.Iban" />
                <InputText class="uppercase" type="text" @bind-Value="_merchant.Iban" placeholder="SKXX XXXX XXXX XXXX XXXX XXXX" />
                <ValidationMessage For="() => _merchant.Iban" />
            </div>
        </EditForm>


Validate call:
private void SubmitPart(EditContext context) {
        var result = context.Validate();

        if(!result) {
            _isSubmitting = false;
            return;
        }

        GoTo(_currentPage+1);
    }
private void SubmitPart(EditContext context) {
        var result = context.Validate();

        if(!result) {
            _isSubmitting = false;
            return;
        }

        GoTo(_currentPage+1);
    }
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Blazor validation - validation message not added?
C#CC# / help
2y ago
Calculation not displaying
C#CC# / help
13mo ago
❔ fluentvalidation custom validation inherit existing validation `MinimumLengthValidator`
C#CC# / help
4y ago
❔ Fluent validation custom method
C#CC# / help
3y ago