I'm creating a application in SyncFusion blazor which has a login page, in this login page I use the following form (+code):
<EditForm Model="@ModelValue">
<DataAnnotationsValidator />
<SfTextBox @ref="user" Placeholder="E-mail" Created="@onCreateUser" CssClass="custom-login" Type="InputType.Email" @bind-Value="@ModelValue.Email"></SfTextBox>
<SfTextBox @ref="password" Placeholder="Password" Created="@onCreatePassword" CssClass="custom-login" Type="InputType.Password" @bind-Value="@ModelValue.Password"></SfTextBox>
<SfCheckBox Label="Stay Signed In" @bind-Checked="rememberUser" CssClass="stay-signed-in-checkbox"></SfCheckBox>
<SfButton CssClass="forgot-password-button">Forgot Password?</SfButton>
<SfButton CssClass="login-button" OnClick="validateForm">LOGIN</SfButton>
</EditForm>
@code{
private User ModelValue = new User();
private void validateForm() {
StateHasChanged();
}
class User
{
public int Id { get; set; }
public string Email { get; set; }
public string Password { get; set; }
}
}
Somehow this code generates warning messages to the user when theres no "@" and characters after the "@" in the email field:
Error translated: "Use a "@" in the e-mail adress field. In "gtgtg" is missing a "@".
These warning messages look way better than just raw text of my own using data annotations in C#. What I'm trying to achieve is that these checks also occur on my Password field (check if minimum of characters is 7) and check if the fields email and password are not empty when clicking the submit button.
How can I achieve this?
NOTE: Im using Bootstrap 4.
Thanks in advance!