I'm trying to do login with blazor, but now the problem is that whenever I type in the data into inputtext fields I get validation error "this field is required" eventhough the information is entered. The model looks like this
public class UserModel { [Required(ErrorMessage = "Name is required")] public string Name { get; set; } [Required(ErrorMessage = "Surname is required")] public string Surname { get; set; } [Required(ErrorMessage = "Email is required")] [EmailAddress(ErrorMessage = "Invalid email format")] public string Email { get; set; } [Required(ErrorMessage = "Password is required")] [MinLength(6, ErrorMessage = "Password must be at least 6 characters long")] public string PasswordHash { get; set; } }I doubt that this part is the problem, but dataAccess file that should contact database and insert data looks like this
public async Task<int> RegisterUser(UserModel user, string connectionString) { user.PasswordHash = BCrypt.Net.BCrypt.HashPassword(user.PasswordHash); string sql = @" INSERT INTO Users (Name, Surname, Email, PasswordHash) VALUES (@Name, @Surname, @Email, @PasswordHash);"; using (IDbConnection connection = new MySqlConnection(connectionString)) { return await connection.ExecuteAsync(sql, user); } }and the form which I try to insert data into looks like this
<EditForm EditContext="@editContext" OnValidSubmit="HandleRegister" FormName="registerForm"><DataAnnotationsValidator /><ValidationSummary /><InputText @bind-Value="userModel.Name" Placeholder="Name" /><InputText @bind-Value="userModel.Surname" Placeholder="Surname" /><InputText @bind-Value="userModel.Email" Placeholder="Email" /><InputText @bind-Value="userModel.PasswordHash" Placeholder="Password" type="password" /><button type="submit">Register</button></EditForm>The problem is like I said, whenever I try to submit input data, I get the verification error message, even if required data is inserted.