I've installed Scott's Kirkland DataAnnotationsExtensions.
In my model I have:
[Numeric]
public double expectedcost { get; set; }
And in my View:
@Html.EditorFor(model => model.expectedcost)
Now, when the page tries to render I get the following error:
Validation type names in unobtrusive client validation rules must be unique. The following validation type was seen more than once: number
Any ideas why I'm getting the error ?
The quick answer is simply remove the attribute
The longer explanation is that by design, validation already adds a data-val-number because it's of type double. By adding a Numeric you are duplicating the validation.
this works:
because the variable is of type string and you are adding the Numeric attribute.
Hope this helps
I basically had the same problem and I managed to solve it with the following piece of code: (As answered here: ASP.NET MVC - "Validation type names must be unique.")
using System; using System.Web.Mvc; And the ValidationRule:
public class RequiredIfValidationRule : ModelClientValidationRule { private const string Chars = "abcdefghijklmnopqrstuvwxyz";
}
I hope this helps.