Can the radzen required validator display the text as long as meet the visible condition without binding to any component?
<RadzenTemplateForm TItem="Registration" Data=@model>
<p>
<RadzenLabel Text="Email" />
<RadzenTextBox Name="Email" @bind-Value=@model.Email />
<RadzenRequiredValidator Text="Enter email" Visible=@(model.IsEmpty)/>
</p>
<RadzenButton ButtonType="ButtonType.Submit" Text="Submit"></RadzenButton>
</RadzenTemplateForm>
Hi @Ck_Cheah,
No, all validator components work when associated with a component. You can use RadzenLabel if you want to show a message on some condition.
1 Like
@korchev , if using label show a message, how to combine with the validator components that working in RadzenTemplateForm? Example, If RadzenTemplateForm have mix with validator and label (to display message), when click submit button, how to validate those not using validator?
You can do so manually by checking the value in the model e.g. if (string.IsNullOrEmpty(model.Email))
@korchev , yes, that is working to validate. But, when first initial the component and model class, by default it's empty string. So, it will trigger the validation and show the error message instead of click submit button then only validate.
That's implementation detail which you can easily work around.