Hi, @Dondon510
I suggest you to use RemoteAttribute to achieve this, you can refer to this simple demo:
remote method
[AcceptVerbs("Get", "Post")]
[AllowAnonymous]
public async Task<IActionResult> IsEmailInUse(string email)
{
//check if the emailAddress already exists or not in database
var user =await _dbContext.users.Where(x => x.Email == email).FirstOrDefaultAsync();
if (user == null)
{
return Json(true);
}
else
{
return Json($"Email {email} is already in use");
}
}
Then add remote attribute in your model
[Required]
[EmailAddress]
[Display(Name = "User Email Address")]
[Remote(action:"IsEmailInUse",controller:"Home")]
public string userEmail { get; set; }
Now, When you type email in <input/>,It will check if the emailAddress already exists or not
-------------------------------------------------------------------------------------------------------------
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Xinran Shen