Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Cannot deactivate default error message for InputSelect in Blazor

$
0
0

I'm using Blazor to create a form where users need to select a "roda" from a dropdown.

The problem is that both the custom error message i defined in the viewModel ("Por favor escolha uma roda") and the default error message appear when no selection is made. I only want my custom error message to be displayed.

How can I ensure that only the custom error message appears?

enter image description here

My ViewModel has a validation rule to show an error message if no "roda" is selected:

        [Required(ErrorMessage = "Por favor escolha uma roda")]        public int? rodaEscolhida { get; set; }

In the form, I'm binding the property like this:

<div class="mb-3"><label for="roda" class="form-label">RODA:</label><InputSelect id="roda" @bind-Value="ProductViewModel.rodaEscolhida" class="form-control"><option hidden value="">Selecione...</option>                @foreach (var component in Components.Where(c => c.tipo == "RODA"))                {<option value="@component.Id">@component.nome</option>                }</InputSelect><ValidationMessage For="() => ProductViewModel.rodaEscolhida" class="text-danger" /></div>

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>