I am using ASP.NET C # MVC2 and I have the following field in the model with the following data annotation validation attributes:
[DisplayName("My Custom Field")]
[Range(long.MinValue, long.MaxValue, ErrorMessage = "The stated My Custom Field value is invalid!")]
public long? MyCustomField{ get; set; }
In the form, this field should allow the user to leave it blank and display a verification message if the user tries to enter a value that cannot be expressed as a number. From a verification point of view, this works as intended and displays the following error messages:
The specified value of My Custom Field is invalid!
My Custom Field must be a number.
The first verification message is a special verification message that I wrote, and the second verification message is the one generated by MVC2. I need to get rid of the second because of its redundancy. How should I do it? In my opinion, I have the following markup
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm())
{ %>
<%:Html.ValidationSummary(false)%>
<% Html.ValidateFor(m => m.MyCustomField); %>