Click here to Skip to main content
16,018,347 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following in a model in MVC:
SQL
[DataType(DataType.Currency, ErrorMessage="*")]
        [Required(ErrorMessage="*")]
        [Range(.50,double.MaxValue, ErrorMessage="*")]
        public Decimal PaymentAmount{get;set;}


When I use the editor for, and the validation for this field, it works pretty well with one exception. If I start typing and get to 25. then I get an error message "The field PaymentAmount must be a number".

My layout is such that I don't want long error messages. So it becomes a really bad usability deal when the layout breaks while you are typing something that you are likely going to finish typing to say 25.0 or 25.5 for example. I have set the error message on all the annotations that I can find, but I still get that. Any tips for what I am missing?

thanks to all who take the time to answer this one

Danny
Posted

1 solution

place your error message, replace of "your message":
it should be working...

SQL
[DataType(DataType.Currency, ErrorMessage="your message")]
        [Required(ErrorMessage="*")]
        [Range(.50,double.MaxValue, ErrorMessage="your message")]
        public Decimal PaymentAmount{get;set;}
 
Share this answer
 
Comments
DannyStaten 3-Sep-11 9:25am    
my problem is that what you have suggested here is not working... I did notice at least that it doesn't show the undesired message until the textbox loses focus, so it isn't as critical.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900