I'm using the Kendo Validator on a Razor Page in a .NET 7 project. I've defined an error message for the EmailAddress attribute on the page model but the Kendo Validator is not using it. I'm using Telerik UI For ASP.NET Core UI version 2022.3.1109.
page model
[DisplayName("Email"), StringLength(256, ErrorMessage = "Email must be no larger than 256 characters"), DataType(DataType.EmailAddress), EmailAddress(ErrorMessage = "Please enter a valid email address")]
public string? EmailAddress { get; set; }
razor
<label asp-for="Input.EmailAddress"></label><br/>
<input asp-for="Input.EmailAddress" class="form-control-large input-rounded"/>
<span asp-validation-for="Input.EmailAddress" class="text-danger"></span>
javascript
var validator = $("#editLocationForm").kendoValidator().data("kendoValidator");
function validateSave() {
if (validator.validate() || validator.errors().length === 0) {
$('#editLocationForm').submit();
$("#SaveConfirmationWindow").data("kendoWindow").close();
} else {
bootstrapWarningMessage("There was an error saving. Please correct the errors and try again.");
}
window.scrollTo(0, 0);
return true;
}
I would expect to see the error message from the attribute -> "Please enter a valid email address".
What I'm getting instead -> "Input.EmailAddress is not valid email".
Any idea how I can get this to display the error message from the attribute? I have Required and StringLength attributes that are properly displaying the attribute error message so maybe a bug with the EmailAddress attribute?