Really struggling with the in-built unobtrusive jquery validation set up by MVC3.
My object has a property like:
[DisplayName("GP")]
[DataType(DataType.Currency)]
[DisplayFormat(NullDisplayText = "$0", DataFormatString = "{0:C0}", ApplyFormatInEditMode = true)]
[Column("gross_profit")]
public decimal? GrossProfit { get; set; }
The EditorFor makes a text box, which is fine, however validation fails because I want users to be able to enter currency prefixes... e.g. $48,000.. client side validation fails, saying the property is not a number.
I don't have a problem writing my own data annotations, and custom model binding for this, but I can't figure out how to stop MVC from automatically putting in that "data-val-number" into the text input just because it's of type decimal.
I believe that "data-val-number" is stopping jquery unobtrusive validation from passing because the input field contains a dollar sign, and maybe a comma.
So i'm not looking for any globalisation tips, rather a way to allow user to enter text like "$48,000" and have this pass validation...
I would want to follow the same approach for percentage values also... e.g. "25%"