This is a field located in my viewmodel:
[Required(ErrorMessage = "Email is missing."), EmailAddress(ErrorMessage = "Email is not valid.")]
public string Email { get; set; }
(EmailAddress
is from the EmailAddressAttribute.EmailAddressAttribute()
type)
This is the relevant part from the HTML:
<div>
<label for="inputEmail">EMAIL</label>
<input id="inputEmail" ng-model="email" asp-for="Email" class="form-control" />
</div>
<div>
<span asp-validation-for="Email" class="text-danger"></span>
</div>
When I type myemail
in the email text box, it will say
Email is invalid
However, when typing myemail@email
, it will be viewed as correct by the view-model (only on the front-end).
public async Task<JsonResult> Register([FromForm]VisitViewModel vm)
Casting like this properly puts the ModelState
on invalid and rejects the email, so that part is okay.
According to this answer though, the frontend should indicate this as invalid
Can anybody explain what is happening here? I'm at an absolute loss.