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?

2 Answers 2

1

Change the type of decimal? into decimal

Sign up to request clarification or add additional context in comments.

Comments

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].

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.