New to Telerik UI for Blazor? Download free 30-day trial

Conditional Form Validation

Environment

Product Form for Blazor

Description

How to apply custom conditional validation, based on user selection?

How to implement conditional required validation for a form field? There are fields that I want to set as required only when another field has a certain value.

How to set dynamic validation for Blazor form fields? I want to update the validation criteria of a TextBox at runtime.

Solution

The TelerikForm supports any validator that is compatible with the Blazor EditForm and EditContext. There are several options to validate form values conditionally:

The Telerik components for Blazor do not perform the actual validation of the model. Validation is managed by the EditContext. The role of the Telerik components is to call EditContext methods, subscribe to EditContext events, retrieve validation messages, and display them. If a validation scenario does not work as expected, check the behavior in a standard Blazor <EditForm> to verify if the issue is related to the Telerik components.

See Also

In this article