Skip to content

Commit b08d1d0

Browse files
docs(common): improve validation Cmessage
1 parent 7863479 commit b08d1d0

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

common-features/input-validation.md

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,33 @@ Simple textbox-like inputs do not have any special behavior. You need to bind th
4040
@using Telerik.Blazor.Components.DatePicker
4141
@using System.ComponentModel.DataAnnotations
4242
43-
<EditForm Model="@person" OnValidSubmit="@HandleValidSubmit">
44-
<DataAnnotationsValidator />
45-
<ValidationSummary />
46-
47-
<p class="name">
48-
Name: <TelerikTextBox bind-Value="@person.Name"></TelerikTextBox>
49-
<ValidationMessage For="@(() => person.Name)"></ValidationMessage>
50-
</p>
51-
<p class="height">
52-
Height (cm): <TelerikNumericTextBox bind-Value="@person.Height" />
53-
<ValidationMessage For="@(() => person.Height)"></ValidationMessage>
54-
</p>
55-
<p class="birthday">
56-
Birthday: <TelerikDateInput bind-Value="@person.Birthday" Format="dd MMMM yyyy"></TelerikDateInput>
57-
<ValidationMessage For="@(() => person.Birthday)"></ValidationMessage>
58-
</p>
59-
<p class="favorite-day">
60-
Birthday: <TelerikDatePicker bind-Value="@person.FavoriteDay" Format="dd MMMM yyyy"></TelerikDatePicker>
61-
<ValidationMessage For="@(() => person.FavoriteDay)"></ValidationMessage>
62-
</p>
63-
<p class="accepts-terms">
64-
Accepts terms: <InputCheckbox bind-Value="@person.AcceptsTerms" />
65-
<ValidationMessage For="@(() => person.AcceptsTerms)"></ValidationMessage>
66-
</p>
67-
68-
<button type="submit">Submit</button>
69-
</EditForm>
43+
<EditForm Model="@person" OnValidSubmit="@HandleValidSubmit">
44+
<DataAnnotationsValidator />
45+
<ValidationSummary />
46+
47+
<p class="name">
48+
Name: <TelerikTextBox bind-Value="@person.Name"></TelerikTextBox>
49+
<ValidationMessage For="@(() => person.Name)"></ValidationMessage>
50+
</p>
51+
<p class="height">
52+
Height (cm): <TelerikNumericTextBox bind-Value="@person.Height" />
53+
<ValidationMessage For="@(() => person.Height)"></ValidationMessage>
54+
</p>
55+
<p class="birthday">
56+
Birthday: <TelerikDateInput bind-Value="@person.Birthday" Format="dd MMMM yyyy"></TelerikDateInput>
57+
<ValidationMessage For="@(() => person.Birthday)"></ValidationMessage>
58+
</p>
59+
<p class="favorite-day">
60+
Birthday: <TelerikDatePicker bind-Value="@person.FavoriteDay" Format="dd MMMM yyyy"></TelerikDatePicker>
61+
<ValidationMessage For="@(() => person.FavoriteDay)"></ValidationMessage>
62+
</p>
63+
<p class="accepts-terms">
64+
Accepts terms: <InputCheckbox bind-Value="@person.AcceptsTerms" />
65+
<ValidationMessage For="@(() => person.AcceptsTerms)"></ValidationMessage>
66+
</p>
67+
68+
<button type="submit">Submit</button>
69+
</EditForm>
7070
7171
@functions {
7272
// Usually this class would be in a different file
@@ -85,9 +85,10 @@ Simple textbox-like inputs do not have any special behavior. You need to bind th
8585
ErrorMessage = "Value for {0} must be between {1:dd MMM yyyy} and {2:dd MMM yyyy}")]
8686
public DateTime Birthday { get; set; }
8787
88-
[Required(ErrorMessage = "You must surely have a favorite day.")]
88+
[Required]
8989
[Range(typeof(DateTime), "1/1/1999", "1/12/2019",
9090
ErrorMessage = "Value for {0} must be between {1:dd MMM yyyy} and {2:dd MMM yyyy}")]
91+
[Display(Name="Your Favourite Day")]
9192
public DateTime FavoriteDay { get; set; }
9293
9394
[Required]

0 commit comments

Comments
 (0)