0

i do have 2 fields in the front end and i do perform model station validation

[Required]
Public decimal? NetPay { get; set; }
[Required]
Public decimal? Tax { get; set; }

if i type some string value in one of the fields in the front end the value on the actionExecuting is always null. Why is that happening? and how to validate it in the model for numeric values?

Anonymous
  • 1
  • 1

2 Answers2

1

Change the type of decimal? into decimal

0

Because null is the default value for decimal? type.

If the properties are actually optional, you can remove [Required] and use other annotations such as [Range].

TZU
  • 936
  • 7
  • 10