Required Validator prompts incorrectly

I'm using below code to show password in the form. It works as expected however if it autofills and when i active the row it shows Required Validator.

What can be the reason?

<RadzenFormField Text="Password" Variant="Radzen.Variant.Text" AllowFloatingLabel="true" Style="display: block">
    <ChildContent>
        <RadzenTextBox Name="txtPass" @bind-Value="@loginModel.password" Visible="@(showPass)" Style="width: 180px" />
        <RadzenPassword Name="txtPass" @bind-Value="@loginModel.password" Visible="@(!showPass)"  Style="width: 180px" />
    </ChildContent>
    <Helper>
        <RadzenRequiredValidator Component="txtPass" Text="Password is required." Style="display: block"></RadzenRequiredValidator>
    </Helper>
    <End>
        <RadzenButton Icon="@(showPass ? "visibility" : "visibility_off")" Click="TogglePassword" Variant="Variant.Text" Size="ButtonSize.Small" />
    </End>
</RadzenFormField>

Recording 2024-01-20 at 07.32.08

Also checked for below documents and none of the password section you didn't use 'show password' function.

That would be nice

Hi @lumosapp

Are you able to debug and check some values? I'm of the assumption that Blazor is not setting the value of @loginModel.password and the textbox/password is being set through the browser. So the validation will fail. See if it's possible to set @loginModel.password at some point with what the browser has already filled in for you. May give an idea of how to get a good work around.

Regards

Paul

You can try triggering validation again in your TogglePassword method.

1 Like