You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>note The Telerik form and validation tools don't add functionality over the standard ones. You should implement the desired custom validations first, and then you can replace it immediately with ours.
2
+
>note The Telerik Blazor validation tools provide a way to display different types of validation messages. The main benefit is consistent styling with all other Telerik Blazor components. The validation tools do not expose API or settings for specific validation logic. You should configure the desired standard or custom validation separately, and then use our UI components to display messages to the user.
Copy file name to clipboardExpand all lines: components/validation/message.md
+24-40Lines changed: 24 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -10,26 +10,23 @@ position: 15
10
10
11
11
# Telerik Validation Message for Blazor
12
12
13
-
The <ahref = "https://www.telerik.com/blazor-ui/validation-message"target="_blank">Telerik Validation Message for Blazor</a> adds customization options on top of the standard <ahref="https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.html.validationextensions.validationmessage?view=aspnet-mvc-5.2"target="_blank">ValidationMessage</a> provided by the framework such as a [Template](#template)or cascading CSS rules from the custom CSS class in the [Class](#class)parameter.
13
+
The <ahref = "https://www.telerik.com/blazor-ui/validation-message"target="_blank">Telerik Validation Message for Blazor</a> adds customization options on top of the standard <ahref="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.forms.validationmessage-1"target="_blank">.NET ValidationMessage</a>, such as [`Template`](#template)and [`Class`](#class)parameters.
14
14
15
-
This article is separated in the following sections:
15
+
## Using Validation Message with TelerikForm
16
16
17
-
*[Basics](#basics)
18
-
*[Template](#template)
19
-
*[Class](#class)
17
+
To enable Telerik Validation Messages for a form field:
20
18
21
-
## Basics
19
+
1. Add a `<TelerikValidationMessage>` tag near the respective `<FormItem>` tag, or [inside a form item `<Template>`]({%slug form-formitems-template%}).
20
+
1. Provide a lambda expression in the `For` parameter that sets the associated property of the model, just like with the standard Blazor `ValidationMessage` component.
21
+
1. (optional) Disable the built-in validation messages of the Telerik Form to avoid repetition. Set `ValidationMessageType="@FormValidationMessageType.None"`.
22
22
23
-
To enable Telerik Validation Messages for a field in the form you should provide a lambda expression in the `For` parameter that notifies the component for which property of the model the validation messages should render, just like with the standard `ValidationMessage` component.
24
-
25
-
>caption Enable Telerik Validation Message in a Form
23
+
>caption Use Telerik Validation Message in a TelerikForm
26
24
27
25
````CSHTML
28
-
@* Use the TelerikValidationMessage component to render validation messages and disable the built-in validation messages from the Telerik Form*@
1. Replace the `<ValidationMessage>` tags with `<TelerikValidationMessage>` tags.
69
+
1. Provide a lambda expression in the `For` parameter that sets the associated property of the model, just like with the standard Blazor `ValidationMessage` component.
72
70
73
-
>caption Enable Telerik Validation Message in an EditForm
71
+
>caption Use Telerik ValidationMessage in an EditForm
74
72
75
73
````CSHTML
76
-
@* Enable the Telerik Validation Message in the standard EditForm *@
77
-
78
74
@using System.ComponentModel.DataAnnotations
79
75
80
76
<EditForm Model="@customer" width="600px">
@@ -110,20 +106,14 @@ To enable Telerik Validation Messages for a field in the form you should provide
Allows you to control the rendering of the validation messages. The `context` represents an `IEnumerable<string>` collection of all messages for the property.
113
+
The `TelerikValidationMessage` allows you to control its rendering via a nested `<Template>` tag. The `context` represents an `IEnumerable<string>` collection of all messages for this model property.
124
114
125
115
````CSHTML
126
-
@* Use the Template to customize the rendering of the validation message *@
116
+
@using System.ComponentModel.DataAnnotations
127
117
128
118
<style>
129
119
.custom-validation-message {
@@ -132,9 +122,8 @@ Allows you to control the rendering of the validation messages. The `context` re
0 commit comments