Steps to reproduce:
- Create a new MVC 5 project with Individual User Accounts.
- Look at the
ErrorMessagespecified inRegisterViewModelfor theConfirmPasswordproperty. It is "The password and confirmation password do not match.". - Build and run the application, and try to register with non-matching passwords. I'll se the error message "'Confirm password' and 'Password' do not match.", instead of the one specified in the model.
It seems like a custom ErrorMessage property on the Compare attribute isn't working. Even if I specify a ErrorMessage, the validation still shows some sort of default message instead.
This work with System.Web.Mvc.CompareAttribute, but this is now deprecated and you should instead use System.ComponentModel.DataAnnotations.CompareAttribute, which shows this problem.
I add the Compare attribute to a property and specify the ErrorMessage as follows:
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match. I'll even add some random text!")]
public string ConfirmPassword { get; set; }
the expected result would be (but this isn't what I get):

Instead, I get this "default" error message:

Client side validation is disabled. Am I missing something? This example is taken from the MVC 5 template with Individual User Accounts as authentication.
<add key="ClientValidationEnabled" value="false" />and if I check the Net panel in my developer tool I can see the postback, and the error message in the response HTML. - JLe