I have a field in .net core 2.3 have a requires regular expression validation. I use this Pattern in two views in one view work fine but in other one just show required error and both code is the same. my view mode :
[Required(ErrorMessage = "لطفا تلفن خود را وارد کنید")]
[RegularExpression(@"^((((\+)|(00?))?\d+[\s]?\d+)|(((\+)|(00?))?\d+[\s]?\d+(-((\+)|(00?))?\d+[\s]?\d+)*))$", ErrorMessage = "تلفن وارد شده نامعتبر است")]
public string Phone { get; set; }
my view is :
<label asp-for="LandingRequest.Phone" class="sr-only">تلفن یا موبایل</label>
<input asp-for="LandingRequest.Phone" class="form-control dir-rtl english-phone" placeholder="تلفن یا موبایل">
<span asp-validation-for="LandingRequest.Phone" class="text-danger"></span>
and generated HTML :
<input class="form-control dir-rtl english-phone input-validation-error" placeholder="تلفن یا موبایل" type="text" data-val="true" data-val-regex="تلفن وارد شده نامعتبر است" data-val-regex-pattern="^((((\+)|(00?))?\d+[\s]?\d+)|(((\+)|(00?))?\d+[\s]?\d+(-((\+)|(00?))?\d+[\s]?\d+)*))$" data-val-required="لطفا تلفن خود را وارد کنید" id="LandingRequest_Phone" name="LandingRequest.Phone" value="" aria-describedby="LandingRequest_Phone-error" aria-invalid="true">