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

Why is MudColorPicker validation not working

$
0
0

I can't seem to get the validation working for the MudColorPicker component. Am I using the component or attribute incorrectly?

https://try.mudblazor.com/snippet/wuGeEolkSdRPrmFc

@using System.Text.RegularExpressions@using System.ComponentModel.DataAnnotations<MudGrid><MudItem xs="12" sm="7"><MudPaper Class="pa-4"><MudForm @ref="form" @bind-IsValid="@success" @bind-Errors="@errors"><MudTextField T="string" Label="Username" Required="true" RequiredError="User name is required!" /><MudTextField T="string" Label="Email" Required="true" RequiredError="Email is required!"                          Validation="@(new EmailAddressAttribute() {ErrorMessage = "The email address is invalid"})" /><MudColorPicker Label="Basic Color Picker" @bind-Text="_colorValue"   DisableToolbar="false" PickerVariant="PickerVariant.Inline"                             Required="true" RequiredError="Colour is required!" /></MudForm>   </MudPaper><MudPaper Class="pa-4 mt-4"><MudButton Variant="Variant.Filled" Color="Color.Primary" DisableElevation="true" OnClick="@(()=>form.Validate())">Validate</MudButton><MudButton Variant="Variant.Filled" Color="Color.Secondary" DisableElevation="true" OnClick="@(()=>form.ResetAsync())" Class="mx-2">Reset</MudButton><MudButton Variant="Variant.Filled" DisableElevation="true" OnClick="@(()=>form.ResetValidation())">Reset Validation</MudButton></MudPaper></MudItem><MudItem xs="12" sm="5"><MudPaper Class="pa-4 mud-height-full"><MudText Typo="Typo.subtitle2">@($"Errors ({errors.Length})")</MudText>            @foreach (var error in errors)            {<MudText Color="@Color.Error">@error</MudText>            }</MudPaper></MudItem>
@code {    bool success;    string[] errors = { };    string _colorValue = string.Empty;MudForm form;}

To recreate issue:

  1. Validate - notice no validation for picker
  2. Reset the form
  3. Validate - notice validation for picker
  4. Click on the picker - must reload page BIG ERROR

Viewing all articles
Browse latest Browse all 4839

Trending Articles



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