views:

224

answers:

1

Hello

I have this:

    [Range(1, 1000, ErrorMessage = "Enter a value between 1 and 1000")]
    public object ObjectLimit { get; set; }

Works great, but it doesnt show the error message, it shows some standard "The value '554g' is not valid for the ObjectLimit field."

How do I fix that?

+1  A: 

Your setting a range of valid integers, 554g is not an integer.

Looks like you need a RegulagExpression attribute with the correct expression to match 554g as a correct value.

jfar
But if I use regular expression I cant add a range check too?
molgan
Well, yes, but its not that easy. http://www.regular-expressions.info/numericranges.html
jfar