Hi @prof cegep ,
The minute this line is inserted, the custom error not working. Can you try it on your side?
<button type="submit" disabled="@(!editContext.IsModified() || !editContext.Validate())" class="btn btn-primary edit-btn">@Localizer["Edit_Save"]</button>
Yes, if I use the above code to enable/disable the submit button, it will show the strange behavior : the DataAnnotations validation works well, and we can enable/disable the submit button based on the DataAnnotations validation result, but when submit the form, event the CustomValidator 's method executed, it will not show the error message. This is your problem, right?
To this issue, if you set a break point in the OnValidationRequested event handler, you can see that each time change the field and call the validate method, it will trigger this event, and the message store will clear. So, it will cause the custom error message disappear.
CurrentEditContext.OnValidationRequested += (s, e) =>
messageStore.Clear();
To solve this issue, you could try to remove the above event handler from the CustomValidator. Then the result as below:
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,
Dillion