views:

77

answers:

3

This is my code for validation money type

    [Required(ErrorMessage = "مبلغ پیشنهادی را وارد کنید")]
    [RegularExpression("^[+]?\\d*$", ErrorMessage = "*")]
    public decimal FirstlySum { get; set; }

If I enter a word (such as "asdf") for the textbox corresponding to this property, I get the following error:

The value 'asdf' is not valid for FirstlySum.

The error message doesn't show.

How can I fix this?

A: 

That error message comes up because your data type is decimal. Decimals are numbers, and asdf cannot be converted to a number properly. Try entering something such as "10.00" and see if the error continues.

John Rudy
A: 

you are rigth but i was used RegularExpression

[RegularExpression("^[+]?\\d*$", ErrorMessage = "*")] 

The RegularExpression didn't work.

Ali