0

Is it possible, in addition to adding a range to an decimal? apply increments such as only divisible by 100 to be true?

[Required(ErrorMessage = "Amount is Required")]
[Range(1000, 25000, ErrorMessage = "Loan must be between 1000 and 25000")]
[DisplayName("Amount")]
public decimal? amount { get; set; }

Any help would be much appreciated :-)

iggyweb
  • 2,373
  • 12
  • 47
  • 77
  • 1
    Nothing out of the box that will do that. You need to write your own validation attribute –  Jun 15 '15 at 08:17
  • So maybe a controller function on HttpPost that will check if the amount is divisible by 100 and if not apply a ModelState Error perhaps? – iggyweb Jun 15 '15 at 08:32
  • A custom validation attribute will allow you to apply it to other properties and give you client side validation as well, but if you don't need/want that, then adding a `ModelState` error in the controller would be fine. –  Jun 15 '15 at 08:33
  • Thank you for your help :-) – iggyweb Jun 15 '15 at 08:34
  • you can have a private field and use "Compare " with that.. :) – Dreamweaver Jun 15 '15 at 10:17

0 Answers0