I am new to asp.net core. I have a form which is generated dynamically. I want the validation error message to be "The value must be numeric" instead I get
"The value must be numeric"
"The value 'a' is invalid."
Here is my View Model:
[RegularExpression("^[0-9]*$", ErrorMessage = "The value must be numeric")] public List<int> Units_Service { get; set; }
Here is my form code:
for (int i = 0; i < Model.Workload_Category_Name.Count; i++) { <div class="row"> <div class="col-md-3"> <b><u> @Html.DisplayFor(model => model.Workload_Category_Name[i])</u> </b> </div> <div class="col-md-4"> @Html.TextBoxFor(model => model.Units_Service[i], new { style = "width: 15%", MaskedTextBox = "9999" }) @Html.ValidationMessageFor(model => model.Units_Service[i]) </div> </div> }
Despite the fact, I have put the custom error message in my View Model as shown above, I keep getting the default message "The value '' is invalid". Please what is the solution to this kind of scenario ?
"The value '' is invalid"