Валидация не проходит с OnValidSubmit
Register model
RegisterViewModel registerData
public class RegisterViewModel
{
[Required]
[Display(Name = "Email")]
public string Email { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[Required]
[Compare("Password", ErrorMessage = "Пароли не совпадают")]
[DataType(DataType.Password)]
[Display(Name = "Repeat password")]
public string PasswordConfirm { get; set; }
[Required]
public string Name { get; set; }
[Required]
public string Surname { get; set; }
[Required]
public string Middlename { get; set; }
public Gender_type Gender { get; set; }
public string? Education { get; set; }
public string? Work { get; set; }
public string? Salary { get; set; }
public string? Hobby { get; set; }
public string? Goal { get; set; }
[Range(18, 100)]
public int age;
public int height;
public int weight;
public IBrowserFile photo;
}
Blazor razor page
<Card Shadow="Shadow.Default">
<CardBody>
<EditForm Model="@registerData" OnValidSubmit="@Register">
<DataAnnotationsValidator></DataAnnotationsValidator>
<Microsoft.AspNetCore.Components.Forms.ValidationSummary></Microsoft.AspNetCore.Components.Forms.ValidationSummary>
<Field>
<FieldLabel>
Your Email
</FieldLabel>
<FieldBody>
<TextEdit @bind-Value="@registerData.Email" Placeholder="[email protected]" Role="TextRole.Email" />
</FieldBody>
</Field>
<Field>
<FieldLabel>
Gender
</FieldLabel>
<FieldBody>
<RadioGroup @bind-Value="@registerData.Gender" TValue="Gender_type" Name="gender">
@foreach (var val in Gender_type.GetValues(typeof(Gender_type)).Cast<Gender_type>())
{
<Radio TValue="Gender_type" Value="@val">@(val.ToString())</Radio>
}
</RadioGroup>
</FieldBody>
</Field>
<Field>
<FieldLabel>
Name
</FieldLabel>
<FieldBody>
<TextEdit @bind-Value="@registerData.Name" Role="TextRole.Text" autocomplete="Name" />
</FieldBody>
</Field>
<Field>
<FieldLabel>
Surname
</FieldLabel>
<FieldBody>
<TextEdit @bind-Value="@registerData.Surname" Role="TextRole.Text" autocomplete="Surname" />
</FieldBody>
</Field>
Я ввожу все данные, но валидация не проходит